Skip to content

Commit

Permalink
v2: Update namespace, dependencies. Add PhoneLink & migration task (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrispenny authored Mar 2, 2023
1 parent 51cf94b commit 826eb4e
Show file tree
Hide file tree
Showing 56 changed files with 1,223 additions and 1,338 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: CI

on:
push:
pull_request:
workflow_dispatch:

jobs:
ci:
uses: silverstripe/gha-ci/.github/workflows/ci.yml@v1
12 changes: 0 additions & 12 deletions .scrutinizer.yml

This file was deleted.

39 changes: 0 additions & 39 deletions .travis.yml

This file was deleted.

65 changes: 40 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,59 +1,74 @@
# Silverstripe link module

Experimental module looking at how we could implement a link field and a link data object.
This module provides a Link model and CMS interface for managing different types of links. Including:

* Emails
* External links
* Links to pages within the CMS
* Links to assets within the CMS
* Phone numbers

## Installation

Installation via composer.

### Stable version (GraphQL v3)

`composer require silverstripe/linkfield 1.x-dev`

### Experimental version (GraphQL v4)
### GraphQL v4 - Silverstripe 4

`composer require silverstripe/linkfield 2.x-dev`
`composer require silverstripe/linkfield`

### Known issues
### GraphQL v3 - Silverstripe 4

You may need to add the repository URL into your `composer.json` via the `repositories` field (example below).

```json
"repositories": {
"silverstripe/linkfield": {
"type": "git",
"url": "https://github.com/silverstripe/silverstripe-linkfield.git"
}
},
```
`composer require silverstripe/linkfield:^1`

## Sample usage

```php
<?php
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Link\DBLink;
use SilverStripe\Link\Link;
use SilverStripe\Link\LinkField;
use SilverStripe\LinkField\DBLink;
use SilverStripe\LinkField\Link;
use SilverStripe\LinkField\LinkField;

class Page extends SiteTree
{
private static $db = [
private static array $db = [
'DbLink' => DBLink::class
];

private static $has_one = [
private static array $has_one = [
'HasOneLink' => Link::class,
];

public function getCMSFields()
{
$fields = parent::getCMSFields();

$fields->insertBefore('Title', LinkField::create('HasOneLink'));
$fields->insertBefore('Title', LinkField::create('DbLink'));
$fields->addFieldsToTab(
'Root.Main',
[
LinkField::create('HasOneLink'),
LinkField::create('DbLink'),
]
)

return $fields;
}
}
```

## Migrating from Version `1.0.0` or `dev-master`

Please be aware that in early versions of this module (and in untagged `dev-master`) there were no table names defined
for our `Link` classes. These have now all been defined, which may mean that you need to rename your old tables, or
migrate the data across.

EG: `SilverStripe_LinkField_Models_Link` needs to be migrated to `LinkField_Link`.

## Migrating from Shae Dawson's Linkable module

https://github.com/sheadawson/silverstripe-linkable

Shae Dawson's Linkable module was a much loved, and much used module. It is, unfortunately, no longer maintained. We
have provided some steps and tasks that we hope can be used to migrate your project from Linkable to LinkField.

* [Migraiton docs](docs/en/linkable-migration.md)
8 changes: 4 additions & 4 deletions _config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ Name: linkfield

SilverStripe\Admin\LeftAndMain:
extensions:
- SilverStripe\Link\Extensions\LeftAndMain
- SilverStripe\LinkField\Extensions\LeftAndMain

SilverStripe\Admin\ModalController:
extensions:
- SilverStripe\Link\Extensions\ModalController
- SilverStripe\LinkField\Extensions\ModalController

SilverStripe\Forms\TreeDropdownField:
extensions:
- SilverStripe\Link\Extensions\AjaxField
- SilverStripe\LinkField\Extensions\AjaxField

SilverStripe\CMS\Forms\AnchorSelectorField:
extensions:
- SilverStripe\Link\Extensions\AjaxField
- SilverStripe\LinkField\Extensions\AjaxField
13 changes: 8 additions & 5 deletions _config/types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@
Name: linkfield-types
---

SilverStripe\Link\Type\Registry:
SilverStripe\LinkField\Type\Registry:
types:
cms:
classname: SilverStripe\Link\Models\SiteTreeLink
classname: SilverStripe\LinkField\Models\SiteTreeLink
enabled: true
external:
classname: SilverStripe\Link\Models\ExternalLink
classname: SilverStripe\LinkField\Models\ExternalLink
enabled: true
file:
classname: SilverStripe\Link\Models\FileLink
classname: SilverStripe\LinkField\Models\FileLink
enabled: true
email:
classname: SilverStripe\Link\Models\EmailLink
classname: SilverStripe\LinkField\Models\EmailLink
enabled: true
phone:
classname: SilverStripe\LinkField\Models\PhoneLink
enabled: true
4 changes: 2 additions & 2 deletions _graphql/queries.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'readLinkDescription(dataStr: String!)':
type: LinkDescription
resolver: ['SilverStripe\Link\GraphQL\LinkDescriptionResolver', 'resolve']
resolver: ['SilverStripe\LinkField\GraphQL\LinkDescriptionResolver', 'resolve']
'readLinkTypes(keys: [ID])':
type: '[LinkType]'
resolver: ['SilverStripe\Link\GraphQL\LinkTypeResolver', 'resolve']
resolver: ['SilverStripe\LinkField\GraphQL\LinkTypeResolver', 'resolve']
Loading

0 comments on commit 826eb4e

Please sign in to comment.