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
@ -18,10 +18,10 @@ if(class_exists('SiteTreeCMSWorkflow')) {
|
||||
CMSWorkflowSiteConfigDecorator::apply_active_config();
|
||||
}
|
||||
|
||||
if(@$_GET['db']) {
|
||||
$enabletranslatable = @$_GET['enabletranslatable'];
|
||||
} elseif(@$_SESSION['db']) {
|
||||
$enabletranslatable = @$_SESSION['enabletranslatable'];
|
||||
if (!empty($_GET['db'])) {
|
||||
$enabletranslatable = $_GET['enabletranslatable'];
|
||||
} elseif (!empty($_SESSION['db'])) {
|
||||
$enabletranslatable = $_SESSION['enabletranslatable'];
|
||||
} else {
|
||||
$enabletranslatable = null;
|
||||
}
|
||||
|
@ -56,8 +56,6 @@ class BasicFieldsTestPage extends TestPage
|
||||
'Required' => 'Text',
|
||||
'Text' => 'Varchar',
|
||||
'Textarea' => 'Text',
|
||||
'Required' => 'Varchar',
|
||||
'Readonly' => 'Varchar',
|
||||
'Time' => 'Time',
|
||||
'ToggleCompositeTextField1' => 'Varchar',
|
||||
'ToggleCompositeDropdownField' => 'Varchar',
|
||||
|
@ -2,21 +2,13 @@
|
||||
|
||||
namespace SilverStripe\FrameworkTest\Model;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\Forms\UploadField;
|
||||
|
||||
|
||||
|
||||
|
||||
class Company extends DataObject
|
||||
{
|
||||
|
||||
private static $table_name = 'Company';
|
||||
|
||||
/**
|
||||
@ -75,20 +67,17 @@ class Company extends DataObject
|
||||
public function getCMSFields()
|
||||
{
|
||||
$fields = parent::getCMSFields();
|
||||
$fields->addFieldToTab('Root.Main',
|
||||
$uploadField = UploadField::create('GroupPhotos')
|
||||
);
|
||||
if (method_exists('SilverStripe\\Forms\\UploadField', 'setAllowedFileCategories')) {
|
||||
$fields->addFieldToTab('Root.Main', $uploadField = UploadField::create('GroupPhotos'));
|
||||
$uploadField->setAllowedFileCategories('image');
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
public function validate()
|
||||
{
|
||||
if (!$this->Title) {
|
||||
return new ValidationResult(false, 'Title is required');
|
||||
$result = new ValidationResult();
|
||||
$result->addError('Title is required');
|
||||
return $result;
|
||||
} else {
|
||||
return parent::validate();
|
||||
}
|
||||
@ -102,7 +91,7 @@ class Company extends DataObject
|
||||
public function requireDefaultRecords()
|
||||
{
|
||||
parent::requireDefaultRecords();
|
||||
$companySet = DataObject::get('SilverStripe\\FrameworkTest\\Model\\Company');
|
||||
$companySet = static::get();
|
||||
foreach ($companySet as $company) {
|
||||
$company->delete();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user