Update deprecated API

Code cleanup
This commit is contained in:
Damian Mooyman 2017-01-11 10:47:17 +13:00
parent 8410ccbf0b
commit 813e75a880
3 changed files with 20 additions and 33 deletions

View File

@ -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;
}

View File

@ -56,8 +56,6 @@ class BasicFieldsTestPage extends TestPage
'Required' => 'Text',
'Text' => 'Varchar',
'Textarea' => 'Text',
'Required' => 'Varchar',
'Readonly' => 'Varchar',
'Time' => 'Time',
'ToggleCompositeTextField1' => 'Varchar',
'ToggleCompositeDropdownField' => 'Varchar',

View File

@ -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();
}