-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v2: Update namespace, dependencies. Add PhoneLink & migration task (#54)
- Loading branch information
1 parent
51cf94b
commit 826eb4e
Showing
56 changed files
with
1,223 additions
and
1,338 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'] |
Oops, something went wrong.