mirror of
https://github.com/silverstripe/silverstripe-frameworktest
synced 2024-10-22 11:06:02 +02:00
MNT Behat test LinkField page and LinkField block (#162)
This commit is contained in:
parent
7c1c85f8b4
commit
f8eac086d2
57
code/linkfield/Extensions/ElementContentExtension.php
Normal file
57
code/linkfield/Extensions/ElementContentExtension.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\FrameworkTest\LinkField\Extensions;
|
||||
|
||||
use SilverStripe\Core\Extension;
|
||||
use SilverStripe\LinkField\Form\LinkField;
|
||||
use SilverStripe\LinkField\Form\MultiLinkField;
|
||||
use SilverStripe\LinkField\Models\Link;
|
||||
use SilverStripe\LinkField\Models\EmailLink;
|
||||
use SilverStripe\LinkField\Models\PhoneLink;
|
||||
use SilverStripe\LinkField\Models\SiteTreeLink;
|
||||
|
||||
class ElementContentExtension extends Extension
|
||||
{
|
||||
|
||||
private static bool $inline_editable = true;
|
||||
|
||||
private static array $has_one = [
|
||||
'OneLink' => Link::class,
|
||||
];
|
||||
|
||||
private static $has_many = [
|
||||
'ManyLinks' => Link::class . '.Owner',
|
||||
];
|
||||
|
||||
private static array $owns = [
|
||||
'OneLink',
|
||||
'ManyLinks',
|
||||
];
|
||||
|
||||
private static array $cascade_deletes = [
|
||||
'OneLink',
|
||||
'ManyLinks',
|
||||
];
|
||||
|
||||
private static array $cascade_duplicates = [
|
||||
'OneLink',
|
||||
'ManyLinks',
|
||||
];
|
||||
|
||||
public function updateCMSFields($fields)
|
||||
{
|
||||
$fields->removeByName(['OneLinkID', 'ManyLinks']);
|
||||
$fields->addFieldsToTab(
|
||||
'Root.Main',
|
||||
[
|
||||
LinkField::create('OneLink')
|
||||
->setAllowedTypes([
|
||||
SiteTreeLink::class,
|
||||
EmailLink::class,
|
||||
PhoneLink::class
|
||||
]),
|
||||
MultiLinkField::create('ManyLinks'),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
56
code/linkfield/Extensions/LinkPageExtension.php
Normal file
56
code/linkfield/Extensions/LinkPageExtension.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\FrameworkTest\LinkField\Extensions;
|
||||
|
||||
use SilverStripe\Core\Extension;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\LinkField\Models\Link;
|
||||
use SilverStripe\LinkField\Form\LinkField;
|
||||
use SilverStripe\LinkField\Form\MultiLinkField;
|
||||
use SilverStripe\LinkField\Models\EmailLink;
|
||||
use SilverStripe\LinkField\Models\PhoneLink;
|
||||
use SilverStripe\LinkField\Models\SiteTreeLink;
|
||||
|
||||
class LinkPageExtension extends Extension
|
||||
{
|
||||
private static array $has_one = [
|
||||
'HasOneLink' => Link::class,
|
||||
];
|
||||
|
||||
private static $has_many = [
|
||||
'HasManyLinks' => Link::class . '.Owner',
|
||||
];
|
||||
|
||||
private static array $owns = [
|
||||
'HasOneLink',
|
||||
'HasManyLinks',
|
||||
];
|
||||
|
||||
private static array $cascade_deletes = [
|
||||
'HasOneLink',
|
||||
'HasManyLinks',
|
||||
];
|
||||
|
||||
private static array $cascade_duplicates = [
|
||||
'HasOneLink',
|
||||
'HasManyLinks',
|
||||
];
|
||||
|
||||
public function updateCMSFields(FieldList $fields)
|
||||
{
|
||||
$fields->removeByName(['Content', 'HasOneLinkID', 'HasManyLinks']);
|
||||
|
||||
$fields->addFieldsToTab(
|
||||
'Root.Main',
|
||||
[
|
||||
LinkField::create('HasOneLink')
|
||||
->setAllowedTypes([
|
||||
SiteTreeLink::class,
|
||||
EmailLink::class,
|
||||
PhoneLink::class
|
||||
]),
|
||||
MultiLinkField::create('HasManyLinks'),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user