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';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -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();
|
||||||
}
|
}
|
||||||
@ -102,7 +91,7 @@ class Company extends DataObject
|
|||||||
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();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user