From 7720748b345cdccfcd60d4421860fd97645bc6d5 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 7 Sep 2016 17:10:55 +1200 Subject: [PATCH] Compat with SS4 namespaces See https://github.com/silverstripe/silverstripe-framework/issues/5637 --- _config.php | 8 +- _config/routes.yml | 6 ++ code/BasicFieldsTestPage.php | 98 +++++++++++++---------- code/Company.php | 8 +- code/Employee.php | 9 ++- code/FTPageMakerTask.php | 2 + code/FileUploadRole.php | 4 +- code/FrameworkTestRole.php | 3 + code/FrameworktestRegressSessionAdmin.php | 12 ++- code/GridFieldTestPage.php | 7 ++ code/RelationFieldsTestPage.php | 4 + code/TestFileUploadPage.php | 7 ++ code/TestPage.php | 16 ++-- code/multiform/Page2MultiForm.php | 3 + code/multiform/Page3MultiForm.php | 5 ++ code/multiform/TestMultiForm.php | 6 ++ code/recaptcha/RecaptchaTestPage.php | 8 ++ code/sifr/SifrPage.php | 2 + 18 files changed, 148 insertions(+), 60 deletions(-) create mode 100644 _config/routes.yml diff --git a/_config.php b/_config.php index 97e480a..03f34d2 100644 --- a/_config.php +++ b/_config.php @@ -2,6 +2,10 @@ use SilverStripe\Security\Member; use SilverStripe\CMS\Model\SiteTree; +use SilverStripe\Assets\File; +use SilverStripe\SiteConfig\SiteConfig; +use SilverStripe\Control\Director; + Member::add_extension('FrameworkTestRole'); @@ -14,10 +18,6 @@ if(class_exists('SiteTreeCMSWorkflow')) { CMSWorkflowSiteConfigDecorator::apply_active_config(); } -Director::addRules(100, array( - 'dev/regress/$Action/$ID' => 'FrameworktestRegressSessionAdmin' -)); - if(@$_GET['db']) { $enabletranslatable = @$_GET['enabletranslatable']; } elseif(@$_SESSION['db']) { diff --git a/_config/routes.yml b/_config/routes.yml new file mode 100644 index 0000000..d9672c2 --- /dev/null +++ b/_config/routes.yml @@ -0,0 +1,6 @@ +--- +Name: frameworktestroutes +--- +SilverStripe\Control\Director: + rules: + 'dev/regress/$Action/$ID': 'FrameworktestRegressSessionAdmin' diff --git a/code/BasicFieldsTestPage.php b/code/BasicFieldsTestPage.php index 0621ddc..8f8acb6 100644 --- a/code/BasicFieldsTestPage.php +++ b/code/BasicFieldsTestPage.php @@ -4,6 +4,20 @@ use SilverStripe\ORM\DataObject; use SilverStripe\FrameworkTest\Model\TestCategory; use SilverStripe\FrameworkTest\Model\TestPage; use SilverStripe\FrameworkTest\Model\TestPage_Controller; +use SilverStripe\Core\Object; +use SilverStripe\Forms\TextField; +use SilverStripe\Forms\SelectionGroup_Item; +use SilverStripe\Forms\FieldList; +use SilverStripe\Forms\AssetField; +use SilverStripe\Forms\UploadField; +use SilverStripe\Forms\LabelField; +use SilverStripe\Forms\LiteralField; +use SilverStripe\Forms\DropdownField; +use SilverStripe\Forms\CheckboxField; +use SilverStripe\Forms\FieldGroup; +use SilverStripe\Forms\CompositeField; +use SilverStripe\Forms\RequiredFields; + class BasicFieldsTestPage extends TestPage { @@ -46,17 +60,17 @@ class BasicFieldsTestPage extends TestPage private static $has_one = array( 'Dropdown' => 'SilverStripe\\FrameworkTest\\Model\\TestCategory', 'GroupedDropdown' => 'SilverStripe\\FrameworkTest\\Model\\TestCategory', - 'File' => 'File', - 'AttachedFile' => 'File', - 'Image' => 'Image', + 'File' => 'SilverStripe\\Assets\\File', + 'AttachedFile' => 'SilverStripe\\Assets\\File', + 'Image' => 'SilverStripe\\Assets\\Image', ); private static $has_many = array( - 'HasManyFiles' => 'File', + 'HasManyFiles' => 'SilverStripe\\Assets\\File', ); private static $many_many = array( - 'ManyManyFiles' => 'File', + 'ManyManyFiles' => 'SilverStripe\\Assets\\File', 'MultipleListboxField' => 'SilverStripe\\FrameworkTest\\Model\\TestCategory', ); @@ -132,39 +146,39 @@ class BasicFieldsTestPage extends TestPage $rightTitle = 'This is right title'; $fields->addFieldsToTab('Root.Text', array( - Object::create('TextField', 'Required', 'Required field') + Object::create('SilverStripe\\Forms\\TextField', 'Required', 'Required field') ->setRightTitle('right title'), - Object::create('TextField', 'Validated', 'Validated field (checks range between 1 and 3)'), - Object::create('ReadonlyField', 'Readonly', 'ReadonlyField'), - Object::create('TextareaField', 'Textarea', 'TextareaField - 8 rows') + Object::create('SilverStripe\\Forms\\TextField', 'Validated', 'Validated field (checks range between 1 and 3)'), + Object::create('SilverStripe\\Forms\\ReadonlyField', 'Readonly', 'SilverStripe\\Forms\\ReadonlyField'), + Object::create('SilverStripe\\Forms\\TextareaField', 'Textarea', 'TextareaField - 8 rows') ->setRows(8), - Object::create('TextField', 'Text', 'TextField'), - Object::create('HtmlEditorField', 'HTMLField', 'HtmlEditorField'), - Object::create('EmailField', 'Email', 'EmailField'), - Object::create('PasswordField', 'Password', 'PasswordField'), - Object::create('ConfirmedPasswordField', 'ConfirmedPasswordField', 'ConfirmedPasswordField') + Object::create('SilverStripe\\Forms\\TextField', 'Text', 'SilverStripe\\Forms\\TextField'), + Object::create('SilverStripe\\Forms\\HTMLEditor\\HTMLEditorField', 'HTMLField', 'HtmlEditorField'), + Object::create('SilverStripe\\Forms\\EmailField', 'SilverStripe\\Control\\Email\\Email', 'SilverStripe\\Forms\\EmailField'), + Object::create('SilverStripe\\Forms\\PasswordField', 'Password', 'SilverStripe\\Forms\\PasswordField'), + Object::create('SilverStripe\\Forms\\ConfirmedPasswordField', 'SilverStripe\\Forms\\ConfirmedPasswordField', 'SilverStripe\\Forms\\ConfirmedPasswordField') )); $fields->addFieldsToTab('Root.Numeric', array( - Object::create('NumericField', 'Number', 'NumericField'), - Object::create('CurrencyField', 'Price', 'CurrencyField'), - Object::create('MoneyField', 'Money', 'MoneyField', array('Amount' => 99.99, 'Currency' => 'EUR')), - Object::create('PhoneNumberField', 'PhoneNumber', 'PhoneNumberField'), - Object::create('CreditCardField', 'CreditCard', 'CreditCardField') + Object::create('SilverStripe\\Forms\\NumericField', 'Number', 'SilverStripe\\Forms\\NumericField'), + Object::create('SilverStripe\\Forms\\CurrencyField', 'Price', 'SilverStripe\\Forms\\CurrencyField'), + Object::create('SilverStripe\\Forms\\MoneyField', 'Money', 'SilverStripe\\Forms\\MoneyField', array('Amount' => 99.99, 'Currency' => 'EUR')), + Object::create('SilverStripe\\Forms\\PhoneNumberField', 'PhoneNumber', 'SilverStripe\\Forms\\PhoneNumberField'), + Object::create('SilverStripe\\Forms\\CreditCardField', 'CreditCard', 'SilverStripe\\Forms\\CreditCardField') )); $fields->addFieldsToTab('Root.Option', array( - Object::create('CheckboxField', 'Checkbox', 'CheckboxField'), - Object::create('CheckboxSetField', 'CheckboxSet', 'CheckboxSetField', TestCategory::map()), - Object::create('DropdownField', 'DropdownID', 'DropdownField', TestCategory::map()) + Object::create('SilverStripe\\Forms\\CheckboxField', 'Checkbox', 'SilverStripe\\Forms\\CheckboxField'), + Object::create('SilverStripe\\Forms\\CheckboxSetField', 'CheckboxSet', 'SilverStripe\\Forms\\CheckboxSetField', TestCategory::map()), + Object::create('SilverStripe\\Forms\\DropdownField', 'DropdownID', 'SilverStripe\\Forms\\DropdownField', TestCategory::map()) ->setHasEmptyDefault(true), - Object::create('GroupedDropdownField', 'GroupedDropdownID', + Object::create('SilverStripe\\Forms\\GroupedDropdownField', 'GroupedDropdownID', 'GroupedDropdown', array('Test Categorys' => TestCategory::map()) ), - Object::create('ListboxField', 'MultipleListboxFieldID', 'ListboxField (multiple)', TestCategory::map()) + Object::create('SilverStripe\\Forms\\ListboxField', 'MultipleListboxFieldID', 'ListboxField (multiple)', TestCategory::map()) ->setSize(3), - Object::create('OptionsetField', 'OptionSet', 'OptionSetField', TestCategory::map()), - Object::create('SelectionGroup', 'SelectionGroup', array( + Object::create('SilverStripe\\Forms\\OptionsetField', 'OptionSet', 'OptionSetField', TestCategory::map()), + Object::create('SilverStripe\\Forms\\SelectionGroup', 'SilverStripe\\Forms\\SelectionGroup', array( new SelectionGroup_Item( 'one', TextField::create('SelectionGroupOne', 'one view'), @@ -176,22 +190,22 @@ class BasicFieldsTestPage extends TestPage 'SelectionGroup Option Two' ) )), - Object::create('ToggleCompositeField', 'ToggleCompositeField', 'ToggleCompositeField', new FieldList( - Object::create('TextField', 'ToggleCompositeTextField1'), - Object::create('TextField', 'ToggleCompositeTextField2'), - Object::create('DropdownField', 'ToggleCompositeDropdownField', 'ToggleCompositeDropdownField', TestCategory::map()), - Object::create('TextField', 'ToggleCompositeTextField3') + Object::create('SilverStripe\\Forms\\ToggleCompositeField', 'SilverStripe\\Forms\\ToggleCompositeField', 'SilverStripe\\Forms\\ToggleCompositeField', new FieldList( + Object::create('SilverStripe\\Forms\\TextField', 'ToggleCompositeTextField1'), + Object::create('SilverStripe\\Forms\\TextField', 'ToggleCompositeTextField2'), + Object::create('SilverStripe\\Forms\\DropdownField', 'ToggleCompositeDropdownField', 'ToggleCompositeDropdownField', TestCategory::map()), + Object::create('SilverStripe\\Forms\\TextField', 'ToggleCompositeTextField3') )) )); // All these date/time fields generally have issues saving directly in the CMS $fields->addFieldsToTab('Root.DateTime', array( - $calendarDateField = Object::create('DateField', 'CalendarDate', 'DateField with calendar'), - Object::create('DateField', 'Date', 'DateField'), - $dmyDateField = Object::create('DateField', 'DMYDate', 'DateField with separate fields'), - Object::create('TimeField', 'Time', 'TimeField'), - Object::create('DatetimeField', 'DateTime', 'DateTime'), - $dateTimeShowCalendar = Object::create('DatetimeField', 'DateTimeWithCalendar', 'DateTime with calendar') + $calendarDateField = Object::create('SilverStripe\\Forms\\DateField', 'CalendarDate', 'DateField with calendar'), + Object::create('SilverStripe\\Forms\\DateField', 'Date', 'SilverStripe\\Forms\\DateField'), + $dmyDateField = Object::create('SilverStripe\\Forms\\DateField', 'DMYDate', 'DateField with separate fields'), + Object::create('SilverStripe\\Forms\\TimeField', 'Time', 'SilverStripe\\Forms\\TimeField'), + Object::create('SilverStripe\\Forms\\DatetimeField', 'DateTime', 'DateTime'), + $dateTimeShowCalendar = Object::create('SilverStripe\\Forms\\DatetimeField', 'DateTimeWithCalendar', 'DateTime with calendar') )); $calendarDateField->setConfig('showcalendar', true); $dmyDateField->setConfig('dmyfields', true); @@ -201,7 +215,7 @@ class BasicFieldsTestPage extends TestPage $fields->addFieldsToTab('Root.File', array( AssetField::create('DBFile'), - $bla = UploadField::create('File', 'FileUploadField') + $bla = UploadField::create('SilverStripe\\Assets\\File', 'FileUploadField') ->setDescription($description) ->setRightTitle($rightTitle) ->setConfig('allowedMaxFileNumber', 1) @@ -210,7 +224,7 @@ class BasicFieldsTestPage extends TestPage ->setDescription($description) ->setRightTitle($rightTitle) ->setConfig('canUpload', false), - UploadField::create('Image', 'UploadField for image') + UploadField::create('SilverStripe\\Assets\\Image', 'UploadField for image') ->setDescription($description) ->setRightTitle($rightTitle), UploadField::create('HasManyFiles', 'UploadField for has_many') @@ -230,7 +244,7 @@ class BasicFieldsTestPage extends TestPage } $blacklist = array( - 'DMYDate', 'Required', 'Validated', 'ToggleCompositeField', 'SelectionGroup' + 'DMYDate', 'Required', 'Validated', 'SilverStripe\\Forms\\ToggleCompositeField', 'SilverStripe\\Forms\\SelectionGroup' ); $tabs = array('Root.Text', 'Root.Numeric', 'Root.Option', 'Root.DateTime', 'Root.File'); @@ -264,11 +278,11 @@ class BasicFieldsTestPage extends TestPage $fields->addFieldToTab('Root.Text', $noLabelField, 'Text_disabled'); $fields->addFieldToTab('Root.Text', - LabelField::create('LabelField', 'LabelField') + LabelField::create('SilverStripe\\Forms\\LabelField', 'SilverStripe\\Forms\\LabelField') ); $fields->addFieldToTab('Root.Text', - LiteralField::create('LiteralField', '
LiteralField with some bold text and a link
') + LiteralField::create('SilverStripe\\Forms\\LiteralField', '
LiteralField with some bold text and a link
') ); $fields->addFieldToTab('Root.Text', diff --git a/code/Company.php b/code/Company.php index 269397f..998f014 100644 --- a/code/Company.php +++ b/code/Company.php @@ -3,12 +3,14 @@ namespace SilverStripe\FrameworkTest\Model; -use UploadField; + use SilverStripe\ORM\ValidationResult; use SilverStripe\ORM\DataObject; use SilverStripe\ORM\DB; +use SilverStripe\Forms\UploadField; + @@ -35,7 +37,7 @@ class Company extends DataObject private static $has_many = array( 'Employees' => 'SilverStripe\\FrameworkTest\\Model\\Employee', - 'GroupPhotos' => 'Image' + 'GroupPhotos' => 'SilverStripe\\Assets\\Image' ); private static $many_many = array( @@ -76,7 +78,7 @@ class Company extends DataObject $fields->addFieldToTab('Root.Main', $uploadField = UploadField::create('GroupPhotos') ); - if (method_exists('UploadField', 'setAllowedFileCategories')) { + if (method_exists('SilverStripe\\Forms\\UploadField', 'setAllowedFileCategories')) { $uploadField->setAllowedFileCategories('image'); } diff --git a/code/Employee.php b/code/Employee.php index 0fb6d9b..1540bee 100644 --- a/code/Employee.php +++ b/code/Employee.php @@ -3,11 +3,14 @@ namespace SilverStripe\FrameworkTest\Model; -use NumericField; -use TextField; + + use SilverStripe\ORM\DataObject; use SilverStripe\ORM\DB; +use SilverStripe\Forms\NumericField; +use SilverStripe\Forms\TextField; + @@ -25,7 +28,7 @@ class Employee extends DataObject private static $has_one = array( 'Company' => 'SilverStripe\\FrameworkTest\\Model\\Company', - 'ProfileImage' => 'Image' + 'ProfileImage' => 'SilverStripe\\Assets\\Image' ); private static $belongs_many_many = array( diff --git a/code/FTPageMakerTask.php b/code/FTPageMakerTask.php index 5c663de..60ec10b 100644 --- a/code/FTPageMakerTask.php +++ b/code/FTPageMakerTask.php @@ -1,4 +1,6 @@ 'File', - 'AImage' => 'Image', + 'AFile' => 'SilverStripe\\Assets\\File', + 'AImage' => 'SilverStripe\\Assets\\Image', ); } diff --git a/code/FrameworkTestRole.php b/code/FrameworkTestRole.php index 7eb488c..1d8da90 100644 --- a/code/FrameworkTestRole.php +++ b/code/FrameworkTestRole.php @@ -4,6 +4,9 @@ use SilverStripe\ORM\DataObject; use SilverStripe\ORM\DB; use SilverStripe\ORM\DataExtension; use SilverStripe\Security\Member; +use SilverStripe\Forms\FieldList; +use SilverStripe\Forms\TreeDropdownField; + class FrameworkTestRole extends DataExtension diff --git a/code/FrameworktestRegressSessionAdmin.php b/code/FrameworktestRegressSessionAdmin.php index a34024f..d52ce5a 100644 --- a/code/FrameworktestRegressSessionAdmin.php +++ b/code/FrameworktestRegressSessionAdmin.php @@ -2,6 +2,16 @@ use SilverStripe\Security\Permission; use SilverStripe\Security\Security; +use SilverStripe\Control\Controller; +use SilverStripe\Control\Session; +use SilverStripe\Forms\FormAction; +use SilverStripe\Forms\FieldList; +use SilverStripe\Forms\HeaderField; +use SilverStripe\Forms\LiteralField; +use SilverStripe\Forms\DropdownField; +use SilverStripe\Forms\CheckboxField; +use SilverStripe\Forms\Form; + /** * Starts a test session with various configurations set in session. @@ -43,7 +53,7 @@ class FrameworktestRegressSessionAdmin extends Controller $form = new Form( $this, - 'Form', + 'SilverStripe\\Forms\\Form', new FieldList( new HeaderField('Header1', ($isRunning) ? 'Session is already running' : 'Start new regress session'), new LiteralField('Lit1', diff --git a/code/GridFieldTestPage.php b/code/GridFieldTestPage.php index 5a5b33e..b59903a 100644 --- a/code/GridFieldTestPage.php +++ b/code/GridFieldTestPage.php @@ -2,6 +2,13 @@ use SilverStripe\ORM\DataList; use SilverStripe\FrameworkTest\Model\TestPage; +use SilverStripe\Forms\GridField\GridFieldConfig_RecordEditor; +use SilverStripe\Forms\GridField\GridField; +use SilverStripe\Forms\GridField\GridFieldConfig_RelationEditor; +use SilverStripe\View\Requirements; +use SilverStripe\Forms\FieldList; +use SilverStripe\Forms\Form; + class GridFieldTestPage extends TestPage { diff --git a/code/RelationFieldsTestPage.php b/code/RelationFieldsTestPage.php index 9468bc4..d4feb2b 100644 --- a/code/RelationFieldsTestPage.php +++ b/code/RelationFieldsTestPage.php @@ -3,6 +3,10 @@ use SilverStripe\FrameworkTest\Model\TestCategory; use SilverStripe\FrameworkTest\Model\TestPage; use SilverStripe\FrameworkTest\Model\TestPage_Controller; +use SilverStripe\Forms\CheckboxSetField; +use SilverStripe\Forms\TreeDropdownField; +use SilverStripe\Forms\TreeMultiselectField; + class RelationFieldsTestPage extends TestPage { diff --git a/code/TestFileUploadPage.php b/code/TestFileUploadPage.php index d2d8e0d..1bb0016 100644 --- a/code/TestFileUploadPage.php +++ b/code/TestFileUploadPage.php @@ -3,6 +3,13 @@ use SilverStripe\FrameworkTest\Model\TestPage; use SilverStripe\FrameworkTest\Model\TestPage_Controller; use SilverStripe\Security\Member; +use SilverStripe\Forms\EmailField; +use SilverStripe\Forms\FileField; +use SilverStripe\Forms\UploadField; +use SilverStripe\Forms\FieldList; +use SilverStripe\Forms\FormAction; +use SilverStripe\Forms\Form; + class TestFileUploadPage extends TestPage { diff --git a/code/TestPage.php b/code/TestPage.php index a7a1919..239cea6 100644 --- a/code/TestPage.php +++ b/code/TestPage.php @@ -6,13 +6,19 @@ use Page; use Page_Controller; -use FieldList; -use FormAction; -use Form; -use TextField; -use Email; + + + + + use SilverStripe\ORM\DataObject; use SilverStripe\CMS\Model\SiteTree; +use SilverStripe\Forms\FormAction; +use SilverStripe\Forms\FieldList; +use SilverStripe\Forms\Form; +use SilverStripe\Forms\TextField; +use SilverStripe\Control\Email\Email; + diff --git a/code/multiform/Page2MultiForm.php b/code/multiform/Page2MultiForm.php index 7cb7128..70abcbe 100644 --- a/code/multiform/Page2MultiForm.php +++ b/code/multiform/Page2MultiForm.php @@ -2,6 +2,9 @@ use SilverStripe\ORM\DataObject; use SilverStripe\Security\Member; +use SilverStripe\Forms\TextField; +use SilverStripe\Forms\FieldList; + class Page2MultiForm extends MultiForm { diff --git a/code/multiform/Page3MultiForm.php b/code/multiform/Page3MultiForm.php index d837efe..f37d330 100644 --- a/code/multiform/Page3MultiForm.php +++ b/code/multiform/Page3MultiForm.php @@ -2,6 +2,11 @@ use SilverStripe\ORM\DataObject; use SilverStripe\Security\Member; +use SilverStripe\Forms\LiteralField; +use SilverStripe\Forms\CheckboxField; +use SilverStripe\Forms\FieldList; +use SilverStripe\Forms\TextField; + class Page3MultiForm extends MultiForm { diff --git a/code/multiform/TestMultiForm.php b/code/multiform/TestMultiForm.php index 3886d14..6aa75ce 100644 --- a/code/multiform/TestMultiForm.php +++ b/code/multiform/TestMultiForm.php @@ -1,4 +1,10 @@