From 58e5ebb652792a893d653977618ab1dc5b284b96 Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Fri, 16 Dec 2016 17:10:38 +1300 Subject: [PATCH] Fix controller names, removed Listbox methods, namespacing bugs, template locations --- src/Admin/GridFieldCategorisationConfig.php | 18 ++++++++++-------- src/Admin/GridFieldFormAction.php | 2 +- src/Admin/GridFieldMergeAction.php | 19 ++++++++++--------- ...Controller.php => BlogPost_Controller.php} | 2 +- ...BlogController.php => Blog_Controller.php} | 2 +- src/Forms/GridField/GridFieldAddByDBField.php | 2 +- src/Model/Blog.php | 6 +++--- .../Forms/GridField}/GridFieldAddByDBField.ss | 0 8 files changed, 27 insertions(+), 24 deletions(-) rename src/Controllers/{BlogPostController.php => BlogPost_Controller.php} (72%) rename src/Controllers/{BlogController.php => Blog_Controller.php} (99%) rename templates/{ => SilverStripe/Blog/Forms/GridField}/GridFieldAddByDBField.ss (100%) diff --git a/src/Admin/GridFieldCategorisationConfig.php b/src/Admin/GridFieldCategorisationConfig.php index 0b0f88f..6455903 100644 --- a/src/Admin/GridFieldCategorisationConfig.php +++ b/src/Admin/GridFieldCategorisationConfig.php @@ -2,7 +2,7 @@ namespace SilverStripe\Blog\Admin; -use SilverStripe\Blog\Form\GridField\GridFieldAddByDBField; +use SilverStripe\Blog\Forms\GridField\GridFieldAddByDBField; use SilverStripe\Blog\Admin\GridFieldMergeAction; use SilverStripe\Blog\Model\CategorisationObject; use SilverStripe\Forms\GridField\GridFieldConfig_RecordEditor; @@ -33,13 +33,15 @@ class GridFieldCategorisationConfig extends GridFieldConfig_RecordEditor /** * @var GridFieldDataColumns $columns */ - $columns = $this->getComponentByType('GridFieldDataColumns'); + $columns = $this->getComponentByType('SilverStripe\\Forms\\GridField\\GridFieldDataColumns'); - $columns->setFieldFormatting(array( - 'BlogPostsCount' => function ($value, CategorisationObject $item) { - return $item->BlogPosts()->Count(); - } - )); + $columns->setFieldFormatting( + array( + 'BlogPostsCount' => function ($value, CategorisationObject $item) { + return $item->BlogPosts()->Count(); + } + ) + ); $this->changeColumnOrder(); } @@ -52,7 +54,7 @@ class GridFieldCategorisationConfig extends GridFieldConfig_RecordEditor /** * @var GridFieldDataColumns $columns */ - $columns = $this->getComponentByType('GridFieldDataColumns'); + $columns = $this->getComponentByType('SilverStripe\\Forms\\GridField\\GridFieldDataColumns'); $columns->setDisplayFields( array( diff --git a/src/Admin/GridFieldFormAction.php b/src/Admin/GridFieldFormAction.php index e48ba80..dfcc629 100644 --- a/src/Admin/GridFieldFormAction.php +++ b/src/Admin/GridFieldFormAction.php @@ -2,7 +2,7 @@ namespace SilverStripe\Blog\Admin; -use GridField_FormAction; +use SilverStripe\Forms\GridField\GridField_FormAction; class GridFieldFormAction extends GridField_FormAction { diff --git a/src/Admin/GridFieldMergeAction.php b/src/Admin/GridFieldMergeAction.php index 25d92f4..f932a8e 100644 --- a/src/Admin/GridFieldMergeAction.php +++ b/src/Admin/GridFieldMergeAction.php @@ -2,15 +2,16 @@ namespace SilverStripe\Blog\Admin; -use GridField_ColumnProvider; -use GridField_ActionProvider; -use DropdownField; - -use GridField; -use Controller; use SilverStripe\Blog\Admin\GridFieldFormAction; +use SilverStripe\Control\Controller; +use Silverstripe\Forms\DropdownField; +use SilverStripe\Forms\GridField\GridField; +use SilverStripe\Forms\GridField\GridField_ActionProvider; +use SilverStripe\Forms\GridField\GridField_ColumnProvider; - +/** + * @package blog + */ class GridFieldMergeAction implements GridField_ColumnProvider, GridField_ActionProvider { /** @@ -81,11 +82,11 @@ class GridFieldMergeAction implements GridField_ColumnProvider, GridField_Action public function getColumnContent($gridField, $record, $columnName) { if ($columnName === 'MergeAction' && $record->{$this->childMethod}()->Count() > 0) { - $dropdown = new DropdownField('Target', 'Target', $this->records->exclude('ID', $record->ID)->map()); + $dropdown = DropdownField::create('Target', 'Target', $this->records->exclude('ID', $record->ID)->map()); $dropdown->setAttribute('id', 'Target_'.$record->ID); $prefix = strtolower($this->parentMethod . '-' . $this->childMethod); - $action = GridFieldFormAction::create( + $action = new GridFieldFormAction( $gridField, 'MergeAction' . $record->ID, 'Move', diff --git a/src/Controllers/BlogPostController.php b/src/Controllers/BlogPost_Controller.php similarity index 72% rename from src/Controllers/BlogPostController.php rename to src/Controllers/BlogPost_Controller.php index 56f7dc2..5eb57d1 100644 --- a/src/Controllers/BlogPostController.php +++ b/src/Controllers/BlogPost_Controller.php @@ -8,7 +8,7 @@ use Page_Controller; * @package silverstripe * @subpackage blog */ -class BlogPostController extends Page_Controller +class BlogPost_Controller extends Page_Controller { } diff --git a/src/Controllers/BlogController.php b/src/Controllers/Blog_Controller.php similarity index 99% rename from src/Controllers/BlogController.php rename to src/Controllers/Blog_Controller.php index f95cd04..65ee60c 100644 --- a/src/Controllers/BlogController.php +++ b/src/Controllers/Blog_Controller.php @@ -13,7 +13,7 @@ use SilverStripe\Security\Member; * @package silverstripe * @subpackage blog */ -class BlogController extends Page_Controller +class Blog_Controller extends Page_Controller { /** * @var array diff --git a/src/Forms/GridField/GridFieldAddByDBField.php b/src/Forms/GridField/GridFieldAddByDBField.php index 1e4e577..18c5b47 100644 --- a/src/Forms/GridField/GridFieldAddByDBField.php +++ b/src/Forms/GridField/GridFieldAddByDBField.php @@ -210,7 +210,7 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP $forTemplate->Fields->push($addAction); return array( - $this->targetFragment => $forTemplate->renderWith('SilverStripe\\Blog\\Form\\GridField\\GridFieldAddByDBField') + $this->targetFragment => $forTemplate->renderWith('SilverStripe\\Blog\\Forms\\GridField\\GridFieldAddByDBField') ); } } diff --git a/src/Model/Blog.php b/src/Model/Blog.php index 8479ae3..fde1c84 100644 --- a/src/Model/Blog.php +++ b/src/Model/Blog.php @@ -354,7 +354,7 @@ class Blog extends Page implements PermissionProvider $members = $this->getCandidateUsers()->map()->toArray(); $editorField = ListboxField::create('Editors', 'Editors', $members) - ->setMultiple(true) + // ->setMultiple(true) ->setRightTitle('help') ->setDescription(' An editor has control over specific Blogs, and all posts included within it. Short of being able to assign other editors to a blog, they are able to handle most changes to their assigned blog.
@@ -373,7 +373,7 @@ class Blog extends Page implements PermissionProvider } $writerField = ListboxField::create('Writers', 'Writers', $members) - ->setMultiple(true) + // ->setMultiple(true) ->setRightTitle('help') ->setDescription(' A writer has full control over creating, editing and publishing BlogPosts they have authored or have been assigned to. Writers are unable to edit BlogPosts to which they are not assigned.
@@ -389,7 +389,7 @@ class Blog extends Page implements PermissionProvider } $contributorField = ListboxField::create('Contributors', 'Contributors', $members) - ->setMultiple(true) + // ->setMultiple(true) ->setRightTitle('help') ->setDescription(' Contributors have the ability to create or edit BlogPosts, but are unable to publish without authorisation of an editor. They are also unable to assign other contributing authors to any of their BlogPosts.
diff --git a/templates/GridFieldAddByDBField.ss b/templates/SilverStripe/Blog/Forms/GridField/GridFieldAddByDBField.ss similarity index 100% rename from templates/GridFieldAddByDBField.ss rename to templates/SilverStripe/Blog/Forms/GridField/GridFieldAddByDBField.ss