2016-10-14 03:30:05 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace SilverStripe\ORM\Tests\DataExtensionTest;
|
|
|
|
|
|
|
|
use SilverStripe\Dev\TestOnly;
|
|
|
|
use SilverStripe\Forms\FieldList;
|
|
|
|
use SilverStripe\Forms\TextField;
|
|
|
|
use SilverStripe\ORM\Tests\DataExtensionTest\CMSFieldsBase;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Second level test class.
|
|
|
|
* Tests usage of beforeExtendingCMSFields
|
|
|
|
*/
|
|
|
|
class CMSFieldsChild extends CMSFieldsBase implements TestOnly
|
|
|
|
{
|
2016-12-16 05:34:21 +01:00
|
|
|
private static $table_name = 'DataExtensionTest_CMSFieldsChild';
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
private static $db = array(
|
|
|
|
'ChildField' => 'Varchar(255)',
|
|
|
|
'ChildFieldBeforeExtension' => 'Varchar(255)'
|
|
|
|
);
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
public function getCMSFields()
|
|
|
|
{
|
|
|
|
$this->beforeExtending(
|
|
|
|
'updateCMSFields',
|
|
|
|
function (FieldList $fields) {
|
|
|
|
$fields->addFieldToTab('Root.Test', new TextField('ChildFieldBeforeExtension'));
|
|
|
|
}
|
|
|
|
);
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
$this->afterExtending(
|
|
|
|
'updateCMSFields',
|
|
|
|
function (FieldList $fields) {
|
|
|
|
$fields->removeByName('ExtendedFieldRemove', true);
|
|
|
|
}
|
|
|
|
);
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
$fields = parent::getCMSFields();
|
|
|
|
$fields->addFieldToTab('Root.Test', new TextField('ChildField'));
|
|
|
|
return $fields;
|
|
|
|
}
|
2016-10-14 03:30:05 +02:00
|
|
|
}
|