Taitava\CMSEditLink\CMSEditLink
Class CMSEditLink
CMSEditLinks are instances that can be used to easily generate links to DataObjects' editing pages in the CMS.
The links can be chained infinitely to create "breadcrumbs" that lead to the actual editing page. For example, if
you have a `Book` object and you want ot provide a CMS editing link which also denotes a `Library` object, you can
create the link like this:
```php
$book = Book::get()->byID(1);
$book->CMSEditLink()->via($book->Library(), 'Books');
```
Or create the same link in another way:
```php
$library = Library::get()->byID(1);
$library->CMSEditLink()->hereon($library->Books()->first(), 'Books');
```
Too complex? No problem, you can create just simple links like this one:
```php
$book = Book::get()->byID(1);
$book->CMSEditLink(); // No breadcrumbs for the Library which holds the book.
```
A CMSEditLink instance can be automatically converted to a simple string representing the absolute URL of the link. You can also
modify the link before converting it to a string. CMSEditLinks can be rendered in templates too, and you can also
call the URL() method of a CMSEditLink instance to get the same url.
More details are in README.md.
Synopsis
- // members
- private DataObject $data_object;
- private $action;
- private CMSEditLink $parent_link;
- private CMSEditLink $child_link;
- private $relation_name;
- // methods
- public void __construct()
- public CMSEditLink hereon()
- public CMSEditLink via()
- public void Parent()
- public void Root()
- public array Children()
- private static void resolve_link()
- public static CMSEditLink LinkFor()
- public string __toString()
- public string forTemplate()
- public string URL()
- public string|$this action()
- public DataObject getDataObject()
- public void setDataObject()
- public mixed getRelationName()
- public void setRelationName()
Hierarchy
Extends
- SilverStripe\View\ViewableData
Members
private
- $action
- $child_link — Taitava\CMSEditLink\CMSEditLink
- $data_object — SilverStripe\ORM\DataObject
- $parent_link — Taitava\CMSEditLink\CMSEditLink
- $relation_name
Methods
private
public
- __construct()
- Children()
- LinkFor() — Returns a CMS edit link for the given DataObject.
- Parent()
- Root()
- URL()
- __toString()
- action() — Gets or sets the 'action' part of the link. 'Action' is the last part of the link and in CMS links it's usually 'edit'. Note that if you are using chained links, then only the **last** link's action in the chain is used and all others discarded! See these examples:
- forTemplate()
- getDataObject()
- getRelationName()
- hereon() — This is the opposite of via(). See the documentation of that method for more information.
- setDataObject()
- setRelationName()
- via() — Instructs to chain our link AFTER the link defined as a parameter. An example: ```php class Library extends DataObject { private static $has_many = ['Books' => Book::class], }