mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
FIX refactored classes to use Injectable::create()
This commit is contained in:
parent
87e5cfcad7
commit
2417863ff8
@ -23,11 +23,11 @@ class GridFieldCategorisationConfig extends GridFieldConfig_RecordEditor
|
||||
$this->removeComponentsByType('SilverStripe\\Forms\\GridField\\GridFieldAddNewButton');
|
||||
|
||||
$this->addComponent(
|
||||
new GridFieldAddByDBField('buttons-before-left')
|
||||
GridFieldAddByDBField::create('buttons-before-left')
|
||||
);
|
||||
|
||||
$this->addComponent(
|
||||
new GridFieldMergeAction($mergeRecords, $parentType, $parentMethod, $childMethod)
|
||||
GridFieldMergeAction::create($mergeRecords, $parentType, $parentMethod, $childMethod)
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -4,6 +4,7 @@ namespace SilverStripe\Blog\Admin;
|
||||
|
||||
use SilverStripe\Blog\Admin\GridFieldFormAction;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Core\Injector\Injectable;
|
||||
use Silverstripe\Forms\DropdownField;
|
||||
use SilverStripe\Forms\GridField\GridField;
|
||||
use SilverStripe\Forms\GridField\GridField_ActionProvider;
|
||||
@ -11,6 +12,8 @@ use SilverStripe\Forms\GridField\GridField_ColumnProvider;
|
||||
|
||||
class GridFieldMergeAction implements GridField_ColumnProvider, GridField_ActionProvider
|
||||
{
|
||||
use Injectable;
|
||||
|
||||
/**
|
||||
* List of records to show in the MergeAction column.
|
||||
*
|
||||
@ -83,7 +86,7 @@ class GridFieldMergeAction implements GridField_ColumnProvider, GridField_Action
|
||||
$dropdown->setAttribute('id', 'Target_'.$record->ID);
|
||||
$prefix = strtolower($this->parentMethod . '-' . $this->childMethod);
|
||||
|
||||
$action = new GridFieldFormAction(
|
||||
$action = GridFieldFormAction::create(
|
||||
$gridField,
|
||||
'MergeAction' . $record->ID,
|
||||
'Move',
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Blog\Forms\GridField;
|
||||
|
||||
use SilverStripe\Core\Injector\Injectable;
|
||||
use SilverStripe\Core\Manifest\ModuleLoader;
|
||||
use UnexpectedValueException;
|
||||
use SilverStripe\Control\Controller;
|
||||
@ -18,6 +19,8 @@ use SilverStripe\View\Requirements;
|
||||
|
||||
class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLProvider
|
||||
{
|
||||
use Injectable;
|
||||
|
||||
/**
|
||||
* HTML Fragment to render the field.
|
||||
*
|
||||
@ -81,7 +84,7 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP
|
||||
/**
|
||||
* @var DataObject $obj
|
||||
*/
|
||||
$obj = new $objClass();
|
||||
$obj = $objClass::create();
|
||||
|
||||
if ($obj->hasField($dbField)) {
|
||||
$obj->setCastedField($dbField, $data['gridfieldaddbydbfield'][$obj->ClassName][$dbField]);
|
||||
@ -183,7 +186,7 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP
|
||||
->setAttribute('placeholder', $obj->fieldLabel($dbField))
|
||||
->addExtraClass('no-change-track');
|
||||
|
||||
$addAction = new GridField_FormAction(
|
||||
$addAction = GridField_FormAction::create(
|
||||
$gridField,
|
||||
'add',
|
||||
_t(
|
||||
@ -198,9 +201,9 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP
|
||||
$addAction->setAttribute('data-icon', 'add');
|
||||
$addAction->addExtraClass('btn btn-primary');
|
||||
|
||||
$forTemplate = new ArrayData([]);
|
||||
$forTemplate = ArrayData::create([]);
|
||||
|
||||
$forTemplate->Fields = new ArrayList();
|
||||
$forTemplate->Fields = ArrayList::create();
|
||||
$forTemplate->Fields->push($textField);
|
||||
$forTemplate->Fields->push($addAction);
|
||||
|
||||
|
@ -19,6 +19,6 @@ class GridFieldConfig_BlogPost extends GridFieldConfig_Lumberjack
|
||||
parent::__construct($itemsPerPage);
|
||||
|
||||
$this->removeComponentsByType(GridFieldSiteTreeState::class);
|
||||
$this->addComponent(new GridFieldBlogPostState());
|
||||
$this->addComponent(GridFieldBlogPostState::create());
|
||||
}
|
||||
}
|
||||
|
@ -492,7 +492,7 @@ class BlogController extends PageController
|
||||
*/
|
||||
protected function rssFeed($blogPosts, $link)
|
||||
{
|
||||
$rss = new RSSFeed($blogPosts, $link, $this->MetaTitle, $this->MetaDescription);
|
||||
$rss = RSSFeed::create($blogPosts, $link, $this->MetaTitle, $this->MetaDescription);
|
||||
|
||||
$this->extend('updateRss', $rss);
|
||||
|
||||
|
@ -674,11 +674,11 @@ class BlogPost extends Page
|
||||
// If there is no parent blog, return list undecorated
|
||||
if (!$parent) {
|
||||
$items = $this->Authors()->toArray();
|
||||
return new ArrayList($items);
|
||||
return ArrayList::create($items);
|
||||
}
|
||||
|
||||
// Update all authors
|
||||
$items = new ArrayList();
|
||||
$items = ArrayList::create();
|
||||
foreach ($this->Authors() as $author) {
|
||||
// Add link for each author
|
||||
$author = $author->customise([
|
||||
@ -697,12 +697,12 @@ class BlogPost extends Page
|
||||
*/
|
||||
protected function getStaticCredits()
|
||||
{
|
||||
$items = new ArrayList();
|
||||
$items = ArrayList::create();
|
||||
|
||||
$authors = array_filter(preg_split('/\s*,\s*/', $this->AuthorNames));
|
||||
|
||||
foreach ($authors as $author) {
|
||||
$item = new ArrayData([
|
||||
$item = ArrayData::create([
|
||||
'Name' => $author,
|
||||
]);
|
||||
|
||||
|
@ -112,7 +112,7 @@ class BlogArchiveWidget extends Widget
|
||||
$posts = $posts->limit($this->NumberToDisplay);
|
||||
}
|
||||
|
||||
$archive = new ArrayList();
|
||||
$archive = ArrayList::create();
|
||||
|
||||
if ($posts->count() > 0) {
|
||||
foreach ($posts as $post) {
|
||||
@ -132,7 +132,7 @@ class BlogArchiveWidget extends Widget
|
||||
$title = $date->FormatI18N("%B %Y");
|
||||
}
|
||||
|
||||
$archive->push(new ArrayData([
|
||||
$archive->push(ArrayData::create([
|
||||
'Title' => $title,
|
||||
'Link' => Controller::join_links($this->Blog()->Link('archive'), $year, $month)
|
||||
]));
|
||||
|
@ -89,9 +89,9 @@ class BlogTagsCloudWidget extends Widget
|
||||
$maxTagCount = 0;
|
||||
|
||||
// create DataObjects that can be used to render the tag cloud
|
||||
$tags = new ArrayList();
|
||||
$tags = ArrayList::create();
|
||||
foreach ($records as $record) {
|
||||
$tag = new DataObject();
|
||||
$tag = DataObject::create();
|
||||
$tag->TagName = $record['Title'];
|
||||
$link = $bloglink.'tag/'.$record['URLSegment'];
|
||||
$tag->Link = $link;
|
||||
|
Loading…
Reference in New Issue
Block a user