diff --git a/src/.upgrade.yml b/src/.upgrade.yml index cefd607..44f389c 100644 --- a/src/.upgrade.yml +++ b/src/.upgrade.yml @@ -22,7 +22,12 @@ mappings: GridFieldBlogPostState: SilverStripe\Blog\Forms\GridField\GridFieldBlogPostState GridFieldConfig_BlogPost: SilverStripe\Blog\Forms\GridField\GridFieldConfig_BlogPost BlogArchiveWidget: SilverStripe\Blog\Widgets\BlogArchiveWidget + BlogArchiveWidget_Controller: SilverStripe\Blog\Widgets\BlogArchiveWidgetController BlogCategoriesWidget: SilverStripe\Blog\Widgets\BlogCategoriesWidget + BlogCategoriesWidget_Controller: SilverStripe\Blog\Widgets\BlogCategoriesWidgetController BlogRecentPostsWidget: SilverStripe\Blog\Widgets\BlogRecentPostsWidget + BlogRecentPostsWidget_Controller: SilverStripe\Blog\Widgets\BlogRecentPostsWidgetController BlogTagsCloudWidget: SilverStripe\Blog\Widgets\BlogTagsCloudWidget + BlogTagsCloudWidget_Controller: SilverStripe\Blog\Widgets\BlogTagsCloudWidgetController BlogTagsWidget: SilverStripe\Blog\Widgets\BlogTagsWidget + BlogTagsWidget_Controller: SilverStripe\Blog\Widgets\BlogTagsWidgetController diff --git a/src/Forms/GridField/GridFieldConfig_BlogPost.php b/src/Forms/GridField/GridFieldConfig_BlogPost.php index 74d4a36..aae7be3 100644 --- a/src/Forms/GridField/GridFieldConfig_BlogPost.php +++ b/src/Forms/GridField/GridFieldConfig_BlogPost.php @@ -3,6 +3,7 @@ namespace SilverStripe\Blog\Forms\GridField; use SilverStripe\Lumberjack\Forms\GridFieldConfig_Lumberjack; +use SilverStripe\Lumberjack\Forms\GridFieldSiteTreeState; /** * GridField config necessary for managing a SiteTree object. @@ -19,7 +20,7 @@ class GridFieldConfig_BlogPost extends GridFieldConfig_Lumberjack { parent::__construct($itemsPerPage); - $this->removeComponentsByType('SilverStripe\\Lumberjack\\Forms\\GridFieldSiteTreeState'); + $this->removeComponentsByType(GridFieldSiteTreeState::class); $this->addComponent(new GridFieldBlogPostState()); } } diff --git a/src/Widgets/BlogArchiveWidget.php b/src/Widgets/BlogArchiveWidget.php index 029e421..5ea67f7 100644 --- a/src/Widgets/BlogArchiveWidget.php +++ b/src/Widgets/BlogArchiveWidget.php @@ -2,12 +2,16 @@ namespace SilverStripe\Blog\Widgets; -use SilverStripe\Blog\Model\Blog; - -if (!class_exists('Widget')) { +if (!class_exists('\\SilverStripe\\Widgets\\Model\\Widget')) { return; } +use SilverStripe\Blog\Model\Blog; +use SilverStripe\Control\Controller; +use SilverStripe\Forms\DropdownField; +use SilverStripe\Forms\NumericField; +use SilverStripe\Widgets\Model\Widget; + /** * @method Blog Blog() * @@ -50,7 +54,7 @@ class BlogArchiveWidget extends Widget * @var array */ private static $has_one = array( - 'Blog' => 'SilverStripe\\Blog\\Model\\Blog', + 'Blog' => Blog::class, ); /** @@ -58,13 +62,11 @@ class BlogArchiveWidget extends Widget */ public function getCMSFields() { - $self =& $this; - - $this->beforeUpdateCMSFields(function ($fields) use ($self) { + $this->beforeUpdateCMSFields(function ($fields) { /** * @var Enum $archiveType */ - $archiveType = $self->dbObject('ArchiveType'); + $archiveType = $this->dbObject('ArchiveType'); $type = $archiveType->enumValues(); @@ -76,7 +78,11 @@ class BlogArchiveWidget extends Widget * @var FieldList $fields */ $fields->merge(array( - DropdownField::create('BlogID', _t('BlogArchiveWidget.Blog', 'SilverStripe\\Blog\\Model\\Blog'), Blog::get()->map()), + DropdownField::create( + 'BlogID', + _t('BlogArchiveWidget.Blog', 'Blog'), + Blog::get()->map() + ), DropdownField::create('ArchiveType', _t('BlogArchiveWidget.ArchiveType', 'ArchiveType'), $type), NumericField::create('NumberToDisplay', _t('BlogArchiveWidget.NumberToDisplay', 'No. to Display')) )); @@ -136,7 +142,3 @@ class BlogArchiveWidget extends Widget return $archive; } } - -class BlogArchiveWidget_Controller extends Widget_Controller -{ -} diff --git a/src/Widgets/BlogArchiveWidgetController.php b/src/Widgets/BlogArchiveWidgetController.php new file mode 100644 index 0000000..5e01105 --- /dev/null +++ b/src/Widgets/BlogArchiveWidgetController.php @@ -0,0 +1,14 @@ + 'SilverStripe\\Blog\\Model\\Blog', + 'Blog' => Blog::class, ); /** @@ -51,24 +56,44 @@ class BlogCategoriesWidget extends Widget { $this->beforeUpdateCMSFields(function (FieldList $fields) { $fields[] = DropdownField::create( - 'BlogID', _t('BlogCategoriesWidget.Blog', 'SilverStripe\\Blog\\Model\\Blog'), Blog::get()->map() + 'BlogID', + _t('BlogCategoriesWidget.Blog', 'Blog'), + Blog::get()->map() ); $fields[] = NumericField::create( - 'Limit', _t('BlogCategoriesWidget.Limit.Label', 'Limit'), 0 + 'Limit', + _t('BlogCategoriesWidget.Limit.Label', 'Limit'), + 0 ) - ->setDescription(_t('BlogCategoriesWidget.Limit.Description', 'Limit the number of categories shown by this widget (set to 0 to show all categories).')) + ->setDescription( + _t( + 'BlogCategoriesWidget.Limit.Description', + 'Limit the number of categories shown by this widget (set to 0 to show all categories).' + ) + ) ->setMaxLength(3); $fields[] = DropdownField::create( - 'Order', _t('BlogCategoriesWidget.Sort.Label', 'Sort'), array('Title' => 'Title', 'Created' => 'Created', 'LastEdited' => 'Updated') + 'Order', + _t('BlogCategoriesWidget.Sort.Label', 'Sort'), + array('Title' => 'Title', 'Created' => 'Created', 'LastEdited' => 'Updated') ) - ->setDescription(_t('BlogCategoriesWidget.Sort.Description', 'Change the order of categories shown by this widget.')); + ->setDescription( + _t('BlogCategoriesWidget.Sort.Description', 'Change the order of categories shown by this widget.') + ); $fields[] = DropdownField::create( - 'Direction', _t('BlogCategoriesWidget.Direction.Label', 'Direction'), array('ASC' => 'Ascending', 'DESC' => 'Descending') + 'Direction', + _t('BlogCategoriesWidget.Direction.Label', 'Direction'), + array('ASC' => 'Ascending', 'DESC' => 'Descending') ) - ->setDescription(_t('BlogCategoriesWidget.Direction.Description', 'Change the direction of ordering of categories shown by this widget.')); + ->setDescription( + _t( + 'BlogCategoriesWidget.Direction.Description', + 'Change the direction of ordering of categories shown by this widget.' + ) + ); }); return parent::getCMSFields(); @@ -99,6 +124,4 @@ class BlogCategoriesWidget extends Widget } } -class BlogCategoriesWidget_Controller extends Widget_Controller -{ -} + diff --git a/src/Widgets/BlogCategoriesWidgetController.php b/src/Widgets/BlogCategoriesWidgetController.php new file mode 100644 index 0000000..b891e3a --- /dev/null +++ b/src/Widgets/BlogCategoriesWidgetController.php @@ -0,0 +1,14 @@ + 'SilverStripe\\Blog\\Model\\Blog', + 'Blog' => Blog::class, ); /** @@ -54,7 +57,7 @@ class BlogRecentPostsWidget extends Widget * @var FieldList $fields */ $fields->merge(array( - DropdownField::create('BlogID', _t('BlogRecentPostsWidget.Blog', 'SilverStripe\\Blog\\Model\\Blog'), Blog::get()->map()), + DropdownField::create('BlogID', _t('BlogRecentPostsWidget.Blog', 'Blog'), Blog::get()->map()), NumericField::create('NumberOfPosts', _t('BlogRecentPostsWidget.NumberOfPosts', 'Number of Posts')) )); }); @@ -78,7 +81,3 @@ class BlogRecentPostsWidget extends Widget return array(); } } - -class BlogRecentPostsWidget_Controller extends Widget_Controller -{ -} diff --git a/src/Widgets/BlogRecentPostsWidgetController.php b/src/Widgets/BlogRecentPostsWidgetController.php new file mode 100644 index 0000000..5c0cac0 --- /dev/null +++ b/src/Widgets/BlogRecentPostsWidgetController.php @@ -0,0 +1,14 @@ + 'SilverStripe\\Blog\\Model\\Blog', + 'Blog' => Blog::class, ); /** @@ -50,8 +56,11 @@ class BlogTagsCloudWidget extends Widget * @var FieldList $fields */ $fields->push( - DropdownField::create('BlogID', _t('BlogTagsCloudWidget.Blog', - 'SilverStripe\\Blog\\Model\\Blog'), Blog::get()->map()) + DropdownField::create( + 'BlogID', + _t('BlogTagsCloudWidget.Blog', 'Blog'), + Blog::get()->map() + ) ); }); @@ -109,7 +118,3 @@ class BlogTagsCloudWidget extends Widget return array(); } } - -class BlogTagsCloudWidget_Controller extends Widget_Controller -{ -} diff --git a/src/Widgets/BlogTagsCloudWidgetController.php b/src/Widgets/BlogTagsCloudWidgetController.php new file mode 100644 index 0000000..bfe2f24 --- /dev/null +++ b/src/Widgets/BlogTagsCloudWidgetController.php @@ -0,0 +1,13 @@ + 'SilverStripe\\Blog\\Model\\Blog', + 'Blog' => Blog::class ); /** @@ -51,24 +56,44 @@ class BlogTagsWidget extends Widget { $this->beforeUpdateCMSFields(function (Fieldlist $fields) { $fields[] = DropdownField::create( - 'BlogID', _t('BlogTagsWidget.Blog', 'SilverStripe\\Blog\\Model\\Blog'), Blog::get()->map() + 'BlogID', + _t('BlogTagsWidget.Blog', 'Blog'), + Blog::get()->map() ); $fields[] = NumericField::create( - 'Limit', _t('BlogTagsWidget.Limit.Label', 'Limit'), 0 + 'Limit', + _t('BlogTagsWidget.Limit.Label', 'Limit'), + 0 ) - ->setDescription(_t('BlogTagsWidget.Limit.Description', 'Limit the number of tags shown by this widget (set to 0 to show all tags).')) + ->setDescription( + _t( + 'BlogTagsWidget.Limit.Description', + 'Limit the number of tags shown by this widget (set to 0 to show all tags).' + ) + ) ->setMaxLength(3); $fields[] = DropdownField::create( - 'Order', _t('BlogTagsWidget.Sort.Label', 'Sort'), array('Title' => 'Title', 'Created' => 'Created', 'LastEdited' => 'Updated') + 'Order', + _t('BlogTagsWidget.Sort.Label', 'Sort'), + array('Title' => 'Title', 'Created' => 'Created', 'LastEdited' => 'Updated') ) - ->setDescription(_t('BlogTagsWidget.Sort.Description', 'Change the order of tags shown by this widget.')); + ->setDescription( + _t('BlogTagsWidget.Sort.Description', 'Change the order of tags shown by this widget.') + ); $fields[] = DropdownField::create( - 'Direction', _t('BlogTagsWidget.Direction.Label', 'Direction'), array('ASC' => 'Ascending', 'DESC' => 'Descending') + 'Direction', + _t('BlogTagsWidget.Direction.Label', 'Direction'), + array('ASC' => 'Ascending', 'DESC' => 'Descending') ) - ->setDescription(_t('BlogTagsWidget.Direction.Description', 'Change the direction of ordering of tags shown by this widget.')); + ->setDescription( + _t( + 'BlogTagsWidget.Direction.Description', + 'Change the direction of ordering of tags shown by this widget.' + ) + ); }); return parent::getCMSFields(); @@ -98,7 +123,3 @@ class BlogTagsWidget extends Widget return $query; } } - -class BlogTagsWidget_Controller extends Widget_Controller -{ -} diff --git a/src/Widgets/BlogTagsWidgetController.php b/src/Widgets/BlogTagsWidgetController.php new file mode 100644 index 0000000..07e6f11 --- /dev/null +++ b/src/Widgets/BlogTagsWidgetController.php @@ -0,0 +1,14 @@ +