mirror of
https://github.com/silverstripe/silverstripe-frameworktest
synced 2024-10-22 11:06:02 +02:00
Update deprecated API
Code cleanup
This commit is contained in:
parent
8410ccbf0b
commit
813e75a880
22
_config.php
22
_config.php
@ -13,19 +13,19 @@ Member::add_extension('FileUploadRole');
|
|||||||
SiteTree::add_extension('FrameworkTestSiteTreeExtension');
|
SiteTree::add_extension('FrameworkTestSiteTreeExtension');
|
||||||
File::add_extension('FrameworkTestFileExtension');
|
File::add_extension('FrameworkTestFileExtension');
|
||||||
|
|
||||||
if(class_exists('SiteTreeCMSWorkflow')) {
|
if (class_exists('SiteTreeCMSWorkflow')) {
|
||||||
SiteConfig::add_extension('CMSWorkflowSiteConfigDecorator');
|
SiteConfig::add_extension('CMSWorkflowSiteConfigDecorator');
|
||||||
CMSWorkflowSiteConfigDecorator::apply_active_config();
|
CMSWorkflowSiteConfigDecorator::apply_active_config();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(@$_GET['db']) {
|
if (!empty($_GET['db'])) {
|
||||||
$enabletranslatable = @$_GET['enabletranslatable'];
|
$enabletranslatable = $_GET['enabletranslatable'];
|
||||||
} elseif(@$_SESSION['db']) {
|
} elseif (!empty($_SESSION['db'])) {
|
||||||
$enabletranslatable = @$_SESSION['enabletranslatable'];
|
$enabletranslatable = $_SESSION['enabletranslatable'];
|
||||||
} else {
|
} else {
|
||||||
$enabletranslatable = null;
|
$enabletranslatable = null;
|
||||||
}
|
}
|
||||||
if($enabletranslatable) {
|
if ($enabletranslatable) {
|
||||||
SiteTree::add_extension('Translatable');
|
SiteTree::add_extension('Translatable');
|
||||||
SiteConfig::add_extension('Translatable');
|
SiteConfig::add_extension('Translatable');
|
||||||
}
|
}
|
||||||
|
@ -56,8 +56,6 @@ class BasicFieldsTestPage extends TestPage
|
|||||||
'Required' => 'Text',
|
'Required' => 'Text',
|
||||||
'Text' => 'Varchar',
|
'Text' => 'Varchar',
|
||||||
'Textarea' => 'Text',
|
'Textarea' => 'Text',
|
||||||
'Required' => 'Varchar',
|
|
||||||
'Readonly' => 'Varchar',
|
|
||||||
'Time' => 'Time',
|
'Time' => 'Time',
|
||||||
'ToggleCompositeTextField1' => 'Varchar',
|
'ToggleCompositeTextField1' => 'Varchar',
|
||||||
'ToggleCompositeDropdownField' => 'Varchar',
|
'ToggleCompositeDropdownField' => 'Varchar',
|
||||||
|
@ -2,21 +2,13 @@
|
|||||||
|
|
||||||
namespace SilverStripe\FrameworkTest\Model;
|
namespace SilverStripe\FrameworkTest\Model;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
use SilverStripe\ORM\ValidationResult;
|
use SilverStripe\ORM\ValidationResult;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
use SilverStripe\ORM\DB;
|
use SilverStripe\ORM\DB;
|
||||||
use SilverStripe\Forms\UploadField;
|
use SilverStripe\Forms\UploadField;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Company extends DataObject
|
class Company extends DataObject
|
||||||
{
|
{
|
||||||
|
|
||||||
private static $table_name = 'Company';
|
private static $table_name = 'Company';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,7 +26,7 @@ class Company extends DataObject
|
|||||||
'RelationFieldsTestPage' => 'RelationFieldsTestPage',
|
'RelationFieldsTestPage' => 'RelationFieldsTestPage',
|
||||||
'GridFieldTestPageHasOne' => 'GridFieldTestPage'
|
'GridFieldTestPageHasOne' => 'GridFieldTestPage'
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $has_many = array(
|
private static $has_many = array(
|
||||||
'Employees' => 'SilverStripe\\FrameworkTest\\Model\\Employee',
|
'Employees' => 'SilverStripe\\FrameworkTest\\Model\\Employee',
|
||||||
'GroupPhotos' => 'SilverStripe\\Assets\\Image'
|
'GroupPhotos' => 'SilverStripe\\Assets\\Image'
|
||||||
@ -75,20 +67,17 @@ class Company extends DataObject
|
|||||||
public function getCMSFields()
|
public function getCMSFields()
|
||||||
{
|
{
|
||||||
$fields = parent::getCMSFields();
|
$fields = parent::getCMSFields();
|
||||||
$fields->addFieldToTab('Root.Main',
|
$fields->addFieldToTab('Root.Main', $uploadField = UploadField::create('GroupPhotos'));
|
||||||
$uploadField = UploadField::create('GroupPhotos')
|
$uploadField->setAllowedFileCategories('image');
|
||||||
);
|
|
||||||
if (method_exists('SilverStripe\\Forms\\UploadField', 'setAllowedFileCategories')) {
|
|
||||||
$uploadField->setAllowedFileCategories('image');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validate()
|
public function validate()
|
||||||
{
|
{
|
||||||
if (!$this->Title) {
|
if (!$this->Title) {
|
||||||
return new ValidationResult(false, 'Title is required');
|
$result = new ValidationResult();
|
||||||
|
$result->addError('Title is required');
|
||||||
|
return $result;
|
||||||
} else {
|
} else {
|
||||||
return parent::validate();
|
return parent::validate();
|
||||||
}
|
}
|
||||||
@ -98,15 +87,15 @@ class Company extends DataObject
|
|||||||
{
|
{
|
||||||
return sprintf('%s (%s)', $this->Name, $this->CEO);
|
return sprintf('%s (%s)', $this->Name, $this->CEO);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function requireDefaultRecords()
|
public function requireDefaultRecords()
|
||||||
{
|
{
|
||||||
parent::requireDefaultRecords();
|
parent::requireDefaultRecords();
|
||||||
$companySet = DataObject::get('SilverStripe\\FrameworkTest\\Model\\Company');
|
$companySet = static::get();
|
||||||
foreach ($companySet as $company) {
|
foreach ($companySet as $company) {
|
||||||
$company->delete();
|
$company->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->data() as $companyData) {
|
foreach ($this->data() as $companyData) {
|
||||||
$company = new Company();
|
$company = new Company();
|
||||||
$company->Name = $companyData[0];
|
$company->Name = $companyData[0];
|
||||||
|
Loading…
Reference in New Issue
Block a user