FIX updated traditional array syntax

This commit is contained in:
Franco Springveldt 2017-09-14 10:59:01 +12:00
parent d9d5c01be3
commit e70e051380
23 changed files with 182 additions and 182 deletions

View File

@ -36,11 +36,11 @@ class GridFieldCategorisationConfig extends GridFieldConfig_RecordEditor
$columns = $this->getComponentByType('SilverStripe\\Forms\\GridField\\GridFieldDataColumns'); $columns = $this->getComponentByType('SilverStripe\\Forms\\GridField\\GridFieldDataColumns');
$columns->setFieldFormatting( $columns->setFieldFormatting(
array( [
'BlogPostsCount' => function ($value, CategorisationObject $item) { 'BlogPostsCount' => function ($value, CategorisationObject $item) {
return $item->BlogPosts()->Count(); return $item->BlogPosts()->Count();
} }
) ]
); );
$this->changeColumnOrder(); $this->changeColumnOrder();
@ -57,12 +57,12 @@ class GridFieldCategorisationConfig extends GridFieldConfig_RecordEditor
$columns = $this->getComponentByType('SilverStripe\\Forms\\GridField\\GridFieldDataColumns'); $columns = $this->getComponentByType('SilverStripe\\Forms\\GridField\\GridFieldDataColumns');
$columns->setDisplayFields( $columns->setDisplayFields(
array( [
'Title' => 'Title', 'Title' => 'Title',
'BlogPostsCount' => 'Posts', 'BlogPostsCount' => 'Posts',
'MergeAction' => 'MergeAction', 'MergeAction' => 'MergeAction',
'Actions' => 'Actions' 'Actions' => 'Actions'
) ]
); );
} }
} }

View File

@ -9,7 +9,7 @@ class GridFieldFormAction extends GridField_FormAction
/** /**
* @var array * @var array
*/ */
protected $extraAttributes = array(); protected $extraAttributes = [];
/** /**
* @param array $attributes * @param array $attributes

View File

@ -45,7 +45,7 @@ class GridFieldMergeAction implements GridField_ColumnProvider, GridField_Action
* @param string $parentMethod * @param string $parentMethod
* @param string $childMethod * @param string $childMethod
*/ */
public function __construct($records = array(), $parentType, $parentMethod, $childMethod) public function __construct($records = [], $parentType, $parentMethod, $childMethod)
{ {
$this->records = $records; $this->records = $records;
$this->parentType = $parentType; $this->parentType = $parentType;
@ -70,7 +70,7 @@ class GridFieldMergeAction implements GridField_ColumnProvider, GridField_Action
*/ */
public function getColumnsHandled($gridField) public function getColumnsHandled($gridField)
{ {
return array('MergeAction'); return ['MergeAction'];
} }
/** /**
@ -88,15 +88,15 @@ class GridFieldMergeAction implements GridField_ColumnProvider, GridField_Action
'MergeAction' . $record->ID, 'MergeAction' . $record->ID,
'Move', 'Move',
'merge', 'merge',
array( [
'record' => $record->ID, 'record' => $record->ID,
'target' => $prefix . '-target-record-' . $record->ID, 'target' => $prefix . '-target-record-' . $record->ID,
) ]
); );
$action->setExtraAttributes(array( $action->setExtraAttributes([
'data-target' => $prefix . '-target-record-' . $record->ID 'data-target' => $prefix . '-target-record-' . $record->ID
)); ]);
return $dropdown->Field() . $action->Field() . '<a title="Move posts to" class="MergeActionReveal">move posts to</a>'; return $dropdown->Field() . $action->Field() . '<a title="Move posts to" class="MergeActionReveal">move posts to</a>';
} }
@ -109,7 +109,7 @@ class GridFieldMergeAction implements GridField_ColumnProvider, GridField_Action
*/ */
public function getColumnAttributes($gridField, $record, $columnName) public function getColumnAttributes($gridField, $record, $columnName)
{ {
return array('class' => 'MergeAction'); return ['class' => 'MergeAction'];
} }
/** /**
@ -117,7 +117,7 @@ class GridFieldMergeAction implements GridField_ColumnProvider, GridField_Action
*/ */
public function getColumnMetadata($gridField, $columnName) public function getColumnMetadata($gridField, $columnName)
{ {
return array('title' => 'Move posts to'); return ['title' => 'Move posts to'];
} }
/** /**
@ -125,7 +125,7 @@ class GridFieldMergeAction implements GridField_ColumnProvider, GridField_Action
*/ */
public function getActions($gridField) public function getActions($gridField)
{ {
return array('merge'); return ['merge'];
} }
/** /**

View File

@ -54,9 +54,9 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP
*/ */
public function getActions($gridField) public function getActions($gridField)
{ {
return array( return [
'add', 'add',
); ];
} }
/** /**
@ -94,9 +94,9 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP
__CLASS__ . '.AddFail', __CLASS__ . '.AddFail',
'Unable to save {class} to the database.', 'Unable to save {class} to the database.',
'Unable to add the DataObject.', 'Unable to add the DataObject.',
array( [
'class' => get_class($obj), 'class' => get_class($obj),
) ]
) )
); );
} }
@ -107,9 +107,9 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP
__CLASS__ . '.PermissionFail', __CLASS__ . '.PermissionFail',
'You don\'t have permission to create a {class}.', 'You don\'t have permission to create a {class}.',
'Unable to add the DataObject.', 'Unable to add the DataObject.',
array( [
'class' => get_class($obj) 'class' => get_class($obj)
) ]
) )
); );
} }
@ -198,12 +198,12 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP
$addAction->setAttribute('data-icon', 'add'); $addAction->setAttribute('data-icon', 'add');
$addAction->addExtraClass('btn btn-primary'); $addAction->addExtraClass('btn btn-primary');
$forTemplate = new ArrayData(array()); $forTemplate = new ArrayData([]);
$forTemplate->Fields = new ArrayList(); $forTemplate->Fields = new ArrayList();
$forTemplate->Fields->push($textField); $forTemplate->Fields->push($textField);
$forTemplate->Fields->push($addAction); $forTemplate->Fields->push($addAction);
return array($this->targetFragment => $forTemplate->renderWith(self::class)); return [$this->targetFragment => $forTemplate->renderWith(self::class)];
} }
} }

View File

@ -38,9 +38,9 @@ class GridFieldBlogPostState extends GridFieldSiteTreeState
__CLASS__ . '.Draft', __CLASS__ . '.Draft',
'<i class="btn-icon gridfield-icon btn-icon-pencil"></i> Saved as Draft on {date}', '<i class="btn-icon gridfield-icon btn-icon-pencil"></i> Saved as Draft on {date}',
'State for when a post is saved.', 'State for when a post is saved.',
array( [
'date' => $lastEdited->FormatFromSettings(), 'date' => $lastEdited->FormatFromSettings(),
) ]
); );
} }
@ -51,22 +51,22 @@ class GridFieldBlogPostState extends GridFieldSiteTreeState
if (strtotime($record->PublishDate) > time()) { if (strtotime($record->PublishDate) > time()) {
return _t( return _t(
__CLASS__ . '.Timer', __CLASS__ . '.Timer',
'<i class="gridfield-icon blog-icon-timer"></i> Publish at {date}', '<i class="gridfield-icon blog-icon-timer"></i> Publish at {date}',
'State for when a post is published.', 'State for when a post is published.',
array( [
'date' => $publishDate->FormatFromSettings(), 'date' => $publishDate->FormatFromSettings(),
) ]
) . $modifiedLabel; ) . $modifiedLabel;
} }
return _t( return _t(
__CLASS__ . '.Published', __CLASS__ . '.Published',
'<i class="btn-icon gridfield-icon btn-icon-accept"></i> Published on {date}', '<i class="btn-icon gridfield-icon btn-icon-accept"></i> Published on {date}',
'State for when a post is published.', 'State for when a post is published.',
array( [
'date' => $publishDate->FormatFromSettings(), 'date' => $publishDate->FormatFromSettings(),
) ]
) . $modifiedLabel; ) . $modifiedLabel;
} }
} }
@ -91,12 +91,12 @@ class GridFieldBlogPostState extends GridFieldSiteTreeState
$class = 'gridfield-icon published'; $class = 'gridfield-icon published';
} }
return array( return [
'class' => $class, 'class' => $class,
); ];
} }
} }
return array(); return [];
} }
} }

View File

@ -87,48 +87,48 @@ class Blog extends Page implements PermissionProvider
/** /**
* @var array * @var array
*/ */
private static $db = array( private static $db = [
'PostsPerPage' => 'Int', 'PostsPerPage' => 'Int',
); ];
/** /**
* @var array * @var array
*/ */
private static $has_many = array( private static $has_many = [
'Tags' => BlogTag::class, 'Tags' => BlogTag::class,
'Categories' => BlogCategory::class, 'Categories' => BlogCategory::class,
); ];
/** /**
* @var array * @var array
*/ */
private static $many_many = array( private static $many_many = [
'Editors' => Member::class, 'Editors' => Member::class,
'Writers' => Member::class, 'Writers' => Member::class,
'Contributors' => Member::class, 'Contributors' => Member::class,
); ];
/** /**
* @var array * @var array
*/ */
private static $allowed_children = array( private static $allowed_children = [
BlogPost::class, BlogPost::class,
); ];
/** /**
* @var array * @var array
*/ */
private static $extensions = array( private static $extensions = [
BlogFilter::class, BlogFilter::class,
); ];
/** /**
* @var array * @var array
*/ */
private static $defaults = array( private static $defaults = [
'ProvideComments' => false, 'ProvideComments' => false,
'PostsPerPage' => 10 'PostsPerPage' => 10
); ];
/** /**
* @var string * @var string
@ -182,10 +182,10 @@ class Blog extends Page implements PermissionProvider
*/ */
$fields->addFieldsToTab( $fields->addFieldsToTab(
'Root.Categorisation', 'Root.Categorisation',
array( [
$categories, $categories,
$tags $tags
) ]
); );
$fields->findOrMakeTab('Root.Categorisation')->addExtraClass('blog-cms-categorisation'); $fields->findOrMakeTab('Root.Categorisation')->addExtraClass('blog-cms-categorisation');
@ -408,11 +408,11 @@ class Blog extends Page implements PermissionProvider
$fields->addFieldsToTab( $fields->addFieldsToTab(
'Root.Users', 'Root.Users',
array( [
$editorField, $editorField,
$writerField, $writerField,
$contributorField $contributorField
) ]
); );
return $fields; return $fields;
@ -606,8 +606,8 @@ class Blog extends Page implements PermissionProvider
*/ */
public function providePermissions() public function providePermissions()
{ {
return array( return [
Blog::MANAGE_USERS => array( Blog::MANAGE_USERS => [
'name' => _t( 'name' => _t(
__CLASS__ . '.PERMISSION_MANAGE_USERS_DESCRIPTION', __CLASS__ . '.PERMISSION_MANAGE_USERS_DESCRIPTION',
'Manage users for individual blogs' 'Manage users for individual blogs'
@ -618,8 +618,8 @@ class Blog extends Page implements PermissionProvider
), ),
'category' => _t(__CLASS__ . '.PERMISSIONS_CATEGORY', 'Blog permissions'), 'category' => _t(__CLASS__ . '.PERMISSIONS_CATEGORY', 'Blog permissions'),
'sort' => 100 'sort' => 100
) ]
); ];
} }
/** /**
@ -644,7 +644,7 @@ class Blog extends Page implements PermissionProvider
// Must check if the method exists or else an error occurs when changing page type // Must check if the method exists or else an error occurs when changing page type
if ($this->hasMethod('Editors')) { if ($this->hasMethod('Editors')) {
foreach (array($this->Editors(), $this->Writers(), $this->Contributors()) as $levels) { foreach ([$this->Editors(), $this->Writers(), $this->Contributors()] as $levels) {
foreach ($levels as $user) { foreach ($levels as $user) {
if (!$user->inGroup($group)) { if (!$user->inGroup($group)) {
$user->Groups()->add($group); $user->Groups()->add($group);

View File

@ -40,24 +40,24 @@ class BlogCategory extends DataObject implements CategorisationObject
/** /**
* @var array * @var array
*/ */
private static $db = array( private static $db = [
'Title' => 'Varchar(255)', 'Title' => 'Varchar(255)',
'URLSegment' => 'Varchar(255)' 'URLSegment' => 'Varchar(255)'
); ];
/** /**
* @var array * @var array
*/ */
private static $has_one = array( private static $has_one = [
'Blog' => Blog::class, 'Blog' => Blog::class,
); ];
/** /**
* @var array * @var array
*/ */
private static $belongs_many_many = array( private static $belongs_many_many = [
'BlogPosts' => BlogPost::class, 'BlogPosts' => BlogPost::class,
); ];
/** /**
* {@inheritdoc} * {@inheritdoc}

View File

@ -14,31 +14,31 @@ class BlogController extends PageController
/** /**
* @var array * @var array
*/ */
private static $allowed_actions = array( private static $allowed_actions = [
'archive', 'archive',
'tag', 'tag',
'category', 'category',
'rss', 'rss',
'profile' 'profile'
); ];
/** /**
* @var array * @var array
*/ */
private static $url_handlers = array( private static $url_handlers = [
'tag/$Tag!/$Rss' => 'tag', 'tag/$Tag!/$Rss' => 'tag',
'category/$Category!/$Rss' => 'category', 'category/$Category!/$Rss' => 'category',
'archive/$Year!/$Month/$Day' => 'archive', 'archive/$Year!/$Month/$Day' => 'archive',
'profile/$URLSegment!' => 'profile' 'profile/$URLSegment!' => 'profile'
); ];
/** /**
* @var array * @var array
*/ */
private static $casting = array( private static $casting = [
'MetaTitle' => 'Text', 'MetaTitle' => 'Text',
'FilterDescription' => 'Text' 'FilterDescription' => 'Text'
); ];
/** /**
* The current Blog Post DataList query. * The current Blog Post DataList query.
@ -243,7 +243,7 @@ class BlogController extends PageController
$tag = $this->request->param('Tag'); $tag = $this->request->param('Tag');
if ($tag) { if ($tag) {
return $dataRecord->Tags() return $dataRecord->Tags()
->filter('URLSegment', array($tag, rawurlencode($tag))) ->filter('URLSegment', [$tag, rawurlencode($tag)])
->first(); ->first();
} }
return null; return null;
@ -287,7 +287,7 @@ class BlogController extends PageController
$category = $this->request->param('Category'); $category = $this->request->param('Category');
if ($category) { if ($category) {
return $dataRecord->Categories() return $dataRecord->Categories()
->filter('URLSegment', array($category, rawurlencode($category))) ->filter('URLSegment', [$category, rawurlencode($category)])
->first(); ->first();
} }
return null; return null;
@ -319,7 +319,7 @@ class BlogController extends PageController
*/ */
public function getFilterDescription() public function getFilterDescription()
{ {
$items = array(); $items = [];
$list = $this->PaginatedList(); $list = $this->PaginatedList();
$currentPage = $list->CurrentPage(); $currentPage = $list->CurrentPage();
@ -329,9 +329,9 @@ class BlogController extends PageController
'SilverStripe\\Blog\\Model\\Blog.FILTERDESCRIPTION_PAGE', 'SilverStripe\\Blog\\Model\\Blog.FILTERDESCRIPTION_PAGE',
'Page {page}', 'Page {page}',
null, null,
array( [
'page' => $currentPage 'page' => $currentPage
) ]
); );
} }
@ -340,9 +340,9 @@ class BlogController extends PageController
'SilverStripe\\Blog\\Model\\Blog.FILTERDESCRIPTION_AUTHOR', 'SilverStripe\\Blog\\Model\\Blog.FILTERDESCRIPTION_AUTHOR',
'By {author}', 'By {author}',
null, null,
array( [
'author' => $author->Title 'author' => $author->Title
) ]
); );
} }
@ -351,9 +351,9 @@ class BlogController extends PageController
'SilverStripe\\Blog\\Model\\Blog.FILTERDESCRIPTION_TAG', 'SilverStripe\\Blog\\Model\\Blog.FILTERDESCRIPTION_TAG',
'Tagged with {tag}', 'Tagged with {tag}',
null, null,
array( [
'tag' => $tag->Title 'tag' => $tag->Title
) ]
); );
} }
@ -362,9 +362,9 @@ class BlogController extends PageController
'SilverStripe\\Blog\\Model\\Blog.FILTERDESCRIPTION_CATEGORY', 'SilverStripe\\Blog\\Model\\Blog.FILTERDESCRIPTION_CATEGORY',
'In category {category}', 'In category {category}',
null, null,
array( [
'category' => $category->Title 'category' => $category->Title
) ]
); );
} }
@ -381,9 +381,9 @@ class BlogController extends PageController
'SilverStripe\\Blog\\Model\\Blog.FILTERDESCRIPTION_DATE', 'SilverStripe\\Blog\\Model\\Blog.FILTERDESCRIPTION_DATE',
'In {date}', 'In {date}',
null, null,
array( [
'date' => $date, 'date' => $date,
) ]
); );
} }

View File

@ -96,10 +96,10 @@ class BlogFilter extends Lumberjack
$excluded = $this->owner->getExcludedSiteTreeClassNames(); $excluded = $this->owner->getExcludedSiteTreeClassNames();
if (!empty($excluded)) { if (!empty($excluded)) {
$pages = BlogPost::get()->filter(array( $pages = BlogPost::get()->filter([
'ParentID' => $this->owner->ID, 'ParentID' => $this->owner->ID,
'ClassName' => $excluded 'ClassName' => $excluded
)); ]);
$gridField = BlogFilterGridField::create( $gridField = BlogFilterGridField::create(
'ChildPages', 'ChildPages',

View File

@ -23,24 +23,24 @@ class BlogMemberExtension extends DataExtension
/** /**
* @var array * @var array
*/ */
private static $db = array( private static $db = [
'URLSegment' => 'Varchar', 'URLSegment' => 'Varchar',
'BlogProfileSummary' => 'Text' 'BlogProfileSummary' => 'Text'
); ];
/** /**
* @var array * @var array
*/ */
private static $has_one = array( private static $has_one = [
'BlogProfileImage' => Image::class 'BlogProfileImage' => Image::class
); ];
/** /**
* @var array * @var array
*/ */
private static $belongs_many_many = array( private static $belongs_many_many = [
'BlogPosts' => BlogPost::class 'BlogPosts' => BlogPost::class
); ];
/** /**
* {@inheritdoc} * {@inheritdoc}

View File

@ -108,7 +108,7 @@ trait BlogObject
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function canCreate($member = null, $context = array()) public function canCreate($member = null, $context = [])
{ {
$extended = $this->extendedCan(__FUNCTION__, $member); $extended = $this->extendedCan(__FUNCTION__, $member);

View File

@ -58,77 +58,77 @@ class BlogPost extends Page
/** /**
* @var array * @var array
*/ */
private static $db = array( private static $db = [
'PublishDate' => 'Datetime', 'PublishDate' => 'Datetime',
'AuthorNames' => 'Varchar(1024)', 'AuthorNames' => 'Varchar(1024)',
'Summary' => 'HTMLText' 'Summary' => 'HTMLText'
); ];
/** /**
* @var array * @var array
*/ */
private static $has_one = array( private static $has_one = [
'FeaturedImage' => Image::class 'FeaturedImage' => Image::class
); ];
/** /**
* @var array * @var array
*/ */
private static $owns = array( private static $owns = [
'FeaturedImage', 'FeaturedImage',
); ];
/** /**
* @var array * @var array
*/ */
private static $many_many = array( private static $many_many = [
'Categories' => BlogCategory::class, 'Categories' => BlogCategory::class,
'Tags' => BlogTag::class, 'Tags' => BlogTag::class,
'Authors' => Member::class 'Authors' => Member::class
); ];
/** /**
* @var array * @var array
*/ */
private static $defaults = array( private static $defaults = [
'ShowInMenus' => false, 'ShowInMenus' => false,
'InheritSideBar' => true, 'InheritSideBar' => true,
'ProvideComments' => true 'ProvideComments' => true
); ];
/** /**
* @var array * @var array
*/ */
private static $extensions = array( private static $extensions = [
BlogPostFilter::class BlogPostFilter::class
); ];
/** /**
* @var array * @var array
*/ */
private static $searchable_fields = array( private static $searchable_fields = [
'Title' 'Title'
); ];
/** /**
* @var array * @var array
*/ */
private static $summary_fields = array( private static $summary_fields = [
'Title' 'Title'
); ];
/** /**
* @var array * @var array
*/ */
private static $casting = array( private static $casting = [
'Excerpt' => 'HTMLText', 'Excerpt' => 'HTMLText',
'Date' => 'DBDatetime' 'Date' => 'DBDatetime'
); ];
/** /**
* @var array * @var array
*/ */
private static $allowed_children = array(); private static $allowed_children = [];
/** /**
* The default sorting lists BlogPosts with an empty PublishDate at the top. * The default sorting lists BlogPosts with an empty PublishDate at the top.
@ -215,7 +215,7 @@ class BlogPost extends Page
$this->beforeUpdateCMSFields(function ($fields) { $this->beforeUpdateCMSFields(function ($fields) {
$uploadField = UploadField::create('FeaturedImage', _t(__CLASS__ . '.FeaturedImage', 'Featured Image')); $uploadField = UploadField::create('FeaturedImage', _t(__CLASS__ . '.FeaturedImage', 'Featured Image'));
$uploadField->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif')); $uploadField->getValidator()->setAllowedExtensions(['jpg', 'jpeg', 'png', 'gif']);
/** /**
* @var FieldList $fields * @var FieldList $fields
@ -232,9 +232,9 @@ class BlogPost extends Page
$summaryHolder = ToggleCompositeField::create( $summaryHolder = ToggleCompositeField::create(
'CustomSummary', 'CustomSummary',
_t(__CLASS__ . '.CUSTOMSUMMARY', 'Add A Custom Summary'), _t(__CLASS__ . '.CUSTOMSUMMARY', 'Add A Custom Summary'),
array( [
$summary, $summary,
) ]
); );
$summaryHolder->setHeadingLevel(4); $summaryHolder->setHeadingLevel(4);
$summaryHolder->addExtraClass('custom-summary'); $summaryHolder->addExtraClass('custom-summary');
@ -244,10 +244,10 @@ class BlogPost extends Page
$urlSegment = $fields->dataFieldByName('URLSegment'); $urlSegment = $fields->dataFieldByName('URLSegment');
$urlSegment->setURLPrefix($this->Parent()->RelativeLink()); $urlSegment->setURLPrefix($this->Parent()->RelativeLink());
$fields->removeFieldsFromTab('Root.Main', array( $fields->removeFieldsFromTab('Root.Main', [
'MenuTitle', 'MenuTitle',
'URLSegment', 'URLSegment',
)); ]);
$authorField = ListboxField::create( $authorField = ListboxField::create(
'Authors', 'Authors',
@ -681,9 +681,9 @@ class BlogPost extends Page
$items = new ArrayList(); $items = new ArrayList();
foreach ($this->Authors() as $author) { foreach ($this->Authors() as $author) {
// Add link for each author // Add link for each author
$author = $author->customise(array( $author = $author->customise([
'URL' => $parent->ProfileLink($author->URLSegment), 'URL' => $parent->ProfileLink($author->URLSegment),
)); ]);
$items->push($author); $items->push($author);
} }
@ -702,9 +702,9 @@ class BlogPost extends Page
$authors = array_filter(preg_split('/\s*,\s*/', $this->AuthorNames)); $authors = array_filter(preg_split('/\s*,\s*/', $this->AuthorNames));
foreach ($authors as $author) { foreach ($authors as $author) {
$item = new ArrayData(array( $item = new ArrayData([
'Name' => $author, 'Name' => $author,
)); ]);
$items->push($item); $items->push($item);
} }

View File

@ -30,7 +30,7 @@ class BlogPostNotifications extends DataExtension
// If comment is spam and notification are set to not send on spam clear the recipient list // If comment is spam and notification are set to not send on spam clear the recipient list
if (Config::inst()->get(__CLASS__, 'notification_on_spam') == false && $comment->IsSpam) { if (Config::inst()->get(__CLASS__, 'notification_on_spam') == false && $comment->IsSpam) {
$list = array(); $list = [];
} }
} }

View File

@ -40,24 +40,24 @@ class BlogTag extends DataObject implements CategorisationObject
/** /**
* @var array * @var array
*/ */
private static $db = array( private static $db = [
'Title' => 'Varchar(255)', 'Title' => 'Varchar(255)',
'URLSegment' => 'Varchar(255)' 'URLSegment' => 'Varchar(255)'
); ];
/** /**
* @var array * @var array
*/ */
private static $has_one = array( private static $has_one = [
'Blog' => Blog::class 'Blog' => Blog::class
); ];
/** /**
* @var array * @var array
*/ */
private static $belongs_many_many = array( private static $belongs_many_many = [
'BlogPosts' => BlogPost::class 'BlogPosts' => BlogPost::class
); ];
/** /**
* {@inheritdoc} * {@inheritdoc}

View File

@ -38,24 +38,24 @@ class BlogArchiveWidget extends Widget
/** /**
* @var array * @var array
*/ */
private static $db = array( private static $db = [
'NumberToDisplay' => 'Int', 'NumberToDisplay' => 'Int',
'ArchiveType' => 'Enum(\'Monthly,Yearly\', \'Monthly\')', 'ArchiveType' => 'Enum(\'Monthly,Yearly\', \'Monthly\')',
); ];
/** /**
* @var array * @var array
*/ */
private static $defaults = array( private static $defaults = [
'NumberOfMonths' => 12, 'NumberOfMonths' => 12,
); ];
/** /**
* @var array * @var array
*/ */
private static $has_one = array( private static $has_one = [
'Blog' => Blog::class, 'Blog' => Blog::class,
); ];
/** /**
* {@inheritdoc} * {@inheritdoc}
@ -77,7 +77,7 @@ class BlogArchiveWidget extends Widget
/** /**
* @var FieldList $fields * @var FieldList $fields
*/ */
$fields->merge(array( $fields->merge([
DropdownField::create( DropdownField::create(
'BlogID', 'BlogID',
_t(__CLASS__ . '.Blog', 'Blog'), _t(__CLASS__ . '.Blog', 'Blog'),
@ -85,7 +85,7 @@ class BlogArchiveWidget extends Widget
), ),
DropdownField::create('ArchiveType', _t(__CLASS__ . '.ArchiveType', 'ArchiveType'), $type), DropdownField::create('ArchiveType', _t(__CLASS__ . '.ArchiveType', 'ArchiveType'), $type),
NumericField::create('NumberToDisplay', _t(__CLASS__ . '.NumberToDisplay', 'No. to Display')) NumericField::create('NumberToDisplay', _t(__CLASS__ . '.NumberToDisplay', 'No. to Display'))
)); ]);
}); });
return parent::getCMSFields(); return parent::getCMSFields();
@ -132,10 +132,10 @@ class BlogArchiveWidget extends Widget
$title = $date->FormatI18N("%B %Y"); $title = $date->FormatI18N("%B %Y");
} }
$archive->push(new ArrayData(array( $archive->push(new ArrayData([
'Title' => $title, 'Title' => $title,
'Link' => Controller::join_links($this->Blog()->Link('archive'), $year, $month) 'Link' => Controller::join_links($this->Blog()->Link('archive'), $year, $month)
))); ]));
} }
} }

View File

@ -37,18 +37,18 @@ class BlogCategoriesWidget extends Widget
/** /**
* @var array * @var array
*/ */
private static $db = array( private static $db = [
'Limit' => 'Int', 'Limit' => 'Int',
'Order' => 'Varchar', 'Order' => 'Varchar',
'Direction' => 'Varchar', 'Direction' => 'Varchar',
); ];
/** /**
* @var array * @var array
*/ */
private static $has_one = array( private static $has_one = [
'Blog' => Blog::class, 'Blog' => Blog::class,
); ];
/** /**
* {@inheritdoc} * {@inheritdoc}
@ -78,7 +78,7 @@ class BlogCategoriesWidget extends Widget
$fields[] = DropdownField::create( $fields[] = DropdownField::create(
'Order', 'Order',
_t(__CLASS__ . '.Sort', 'Sort'), _t(__CLASS__ . '.Sort', 'Sort'),
array('Title' => 'Title', 'Created' => 'Created', 'LastEdited' => 'Updated') ['Title' => 'Title', 'Created' => 'Created', 'LastEdited' => 'Updated']
) )
->setDescription( ->setDescription(
_t(__CLASS__ . '.Sort_Description', 'Change the order of categories shown by this widget.') _t(__CLASS__ . '.Sort_Description', 'Change the order of categories shown by this widget.')
@ -87,7 +87,7 @@ class BlogCategoriesWidget extends Widget
$fields[] = DropdownField::create( $fields[] = DropdownField::create(
'Direction', 'Direction',
_t(__CLASS__ . '.Direction', 'Direction'), _t(__CLASS__ . '.Direction', 'Direction'),
array('ASC' => 'Ascending', 'DESC' => 'Descending') ['ASC' => 'Ascending', 'DESC' => 'Descending']
) )
->setDescription( ->setDescription(
_t( _t(
@ -108,7 +108,7 @@ class BlogCategoriesWidget extends Widget
$blog = $this->Blog(); $blog = $this->Blog();
if (!$blog) { if (!$blog) {
return array(); return [];
} }
$query = $blog->Categories(); $query = $blog->Categories();

View File

@ -36,16 +36,16 @@ class BlogRecentPostsWidget extends Widget
/** /**
* @var array * @var array
*/ */
private static $db = array( private static $db = [
'NumberOfPosts' => 'Int', 'NumberOfPosts' => 'Int',
); ];
/** /**
* @var array * @var array
*/ */
private static $has_one = array( private static $has_one = [
'Blog' => Blog::class, 'Blog' => Blog::class,
); ];
/** /**
* {@inheritdoc} * {@inheritdoc}
@ -56,10 +56,10 @@ class BlogRecentPostsWidget extends Widget
/** /**
* @var FieldList $fields * @var FieldList $fields
*/ */
$fields->merge(array( $fields->merge([
DropdownField::create('BlogID', _t(__CLASS__ . '.Blog', 'Blog'), Blog::get()->map()), DropdownField::create('BlogID', _t(__CLASS__ . '.Blog', 'Blog'), Blog::get()->map()),
NumericField::create('NumberOfPosts', _t(__CLASS__ . '.NumberOfPosts', 'Number of Posts')) NumericField::create('NumberOfPosts', _t(__CLASS__ . '.NumberOfPosts', 'Number of Posts'))
)); ]);
}); });
return parent::getCMSFields(); return parent::getCMSFields();
@ -78,6 +78,6 @@ class BlogRecentPostsWidget extends Widget
->limit($this->NumberOfPosts); ->limit($this->NumberOfPosts);
} }
return array(); return [];
} }
} }

View File

@ -37,14 +37,14 @@ class BlogTagsCloudWidget extends Widget
/** /**
* @var array * @var array
*/ */
private static $db = array(); private static $db = [];
/** /**
* @var array * @var array
*/ */
private static $has_one = array( private static $has_one = [
'Blog' => Blog::class, 'Blog' => Blog::class,
); ];
/** /**
* {@inheritdoc} * {@inheritdoc}
@ -115,6 +115,6 @@ class BlogTagsCloudWidget extends Widget
return $tags; return $tags;
} }
return array(); return [];
} }
} }

View File

@ -36,18 +36,18 @@ class BlogTagsWidget extends Widget
/** /**
* @var array * @var array
*/ */
private static $db = array( private static $db = [
'Limit' => 'Int', 'Limit' => 'Int',
'Order' => 'Varchar', 'Order' => 'Varchar',
'Direction' => 'Varchar', 'Direction' => 'Varchar',
); ];
/** /**
* @var array * @var array
*/ */
private static $has_one = array( private static $has_one = [
'Blog' => Blog::class 'Blog' => Blog::class
); ];
/** /**
* {@inheritdoc} * {@inheritdoc}
@ -77,7 +77,7 @@ class BlogTagsWidget extends Widget
$fields[] = DropdownField::create( $fields[] = DropdownField::create(
'Order', 'Order',
_t(__CLASS__ . '.Sort', 'Sort'), _t(__CLASS__ . '.Sort', 'Sort'),
array('Title' => 'Title', 'Created' => 'Created', 'LastEdited' => 'Updated') ['Title' => 'Title', 'Created' => 'Created', 'LastEdited' => 'Updated']
) )
->setDescription( ->setDescription(
_t(__CLASS__ . '.Sort_Description', 'Change the order of tags shown by this widget.') _t(__CLASS__ . '.Sort_Description', 'Change the order of tags shown by this widget.')
@ -86,7 +86,7 @@ class BlogTagsWidget extends Widget
$fields[] = DropdownField::create( $fields[] = DropdownField::create(
'Direction', 'Direction',
_t(__CLASS__ . '.Direction', 'Direction'), _t(__CLASS__ . '.Direction', 'Direction'),
array('ASC' => 'Ascending', 'DESC' => 'Descending') ['ASC' => 'Ascending', 'DESC' => 'Descending']
) )
->setDescription( ->setDescription(
_t( _t(
@ -107,7 +107,7 @@ class BlogTagsWidget extends Widget
$blog = $this->Blog(); $blog = $this->Blog();
if (!$blog) { if (!$blog) {
return array(); return [];
} }
$query = $blog->Tags(); $query = $blog->Tags();

View File

@ -27,14 +27,14 @@ class BlogPostNotificationsTest extends SapphireTest
$comment $comment
)->toArray(); )->toArray();
$segments = array(); $segments = [];
foreach ($recipients as $recipient) { foreach ($recipients as $recipient) {
array_push($segments, $recipient->URLSegment); array_push($segments, $recipient->URLSegment);
} }
sort($segments); sort($segments);
$this->assertEquals( $this->assertEquals(
array('blog-contributor', 'blog-editor', 'blog-writer'), ['blog-contributor', 'blog-editor', 'blog-writer'],
$segments $segments
); );
} }

View File

@ -43,33 +43,33 @@ class BlogPostTest extends SapphireTest
{ {
$someFutureDate = '2013-10-10 20:00:00'; $someFutureDate = '2013-10-10 20:00:00';
$somePastDate = '2009-10-10 20:00:00'; $somePastDate = '2009-10-10 20:00:00';
return array( return [
// Check this post given the date has passed // Check this post given the date has passed
array($someFutureDate, 'Editor', 'PostA', true), [$someFutureDate, 'Editor', 'PostA', true],
array($someFutureDate, 'Contributor', 'PostA', true), [$someFutureDate, 'Contributor', 'PostA', true],
array($someFutureDate, 'BlogEditor', 'PostA', true), [$someFutureDate, 'BlogEditor', 'PostA', true],
array($someFutureDate, 'Writer', 'PostA', true), [$someFutureDate, 'Writer', 'PostA', true],
// Check unpublished pages // Check unpublished pages
array($somePastDate, 'Editor', 'PostA', true), [$somePastDate, 'Editor', 'PostA', true],
array($somePastDate, 'Contributor', 'PostA', true), [$somePastDate, 'Contributor', 'PostA', true],
array($somePastDate, 'BlogEditor', 'PostA', true), [$somePastDate, 'BlogEditor', 'PostA', true],
array($somePastDate, 'Writer', 'PostA', true), [$somePastDate, 'Writer', 'PostA', true],
// Test a page that was authored by another user // Test a page that was authored by another user
// Check this post given the date has passed // Check this post given the date has passed
array($someFutureDate, 'Editor', 'FirstBlogPost', true), [$someFutureDate, 'Editor', 'FirstBlogPost', true],
array($someFutureDate, 'Contributor', 'FirstBlogPost', true), [$someFutureDate, 'Contributor', 'FirstBlogPost', true],
array($someFutureDate, 'BlogEditor', 'FirstBlogPost', true), [$someFutureDate, 'BlogEditor', 'FirstBlogPost', true],
array($someFutureDate, 'Writer', 'FirstBlogPost', true), [$someFutureDate, 'Writer', 'FirstBlogPost', true],
// Check future pages - non-editors shouldn't be able to see this // Check future pages - non-editors shouldn't be able to see this
array($somePastDate, 'Editor', 'FirstBlogPost', true), [$somePastDate, 'Editor', 'FirstBlogPost', true],
array($somePastDate, 'Contributor', 'FirstBlogPost', false), [$somePastDate, 'Contributor', 'FirstBlogPost', false],
array($somePastDate, 'BlogEditor', 'FirstBlogPost', false), [$somePastDate, 'BlogEditor', 'FirstBlogPost', false],
array($somePastDate, 'Writer', 'FirstBlogPost', false), [$somePastDate, 'Writer', 'FirstBlogPost', false],
); ];
} }
public function testCandidateAuthors() public function testCandidateAuthors()

View File

@ -23,12 +23,12 @@ class BlogTagsCloudWidgetTest extends SapphireTest
$widget = new BlogTagsCloudWidget(); $widget = new BlogTagsCloudWidget();
$fields = $widget->getCMSFields(); $fields = $widget->getCMSFields();
$names = array(); $names = [];
foreach ($fields as $field) { foreach ($fields as $field) {
array_push($names, $field->getName()); array_push($names, $field->getName());
} }
$expected = array('Title', 'Enabled', 'BlogID'); $expected = ['Title', 'Enabled', 'BlogID'];
$this->assertEquals($expected, $names); $this->assertEquals($expected, $names);
} }

View File

@ -325,7 +325,7 @@ class BlogTest extends SapphireTest
// Request first tag // Request first tag
$this->requestURL($controller, 'first-post/tag/first-tag'); $this->requestURL($controller, 'first-post/tag/first-tag');
$this->assertIDsEquals( $this->assertIDsEquals(
array($firstPostID, $firstFuturePostID, $secondFuturePostID), [$firstPostID, $firstFuturePostID, $secondFuturePostID],
$controller->PaginatedList() $controller->PaginatedList()
); );
} }
@ -343,7 +343,7 @@ class BlogTest extends SapphireTest
// Request 2013 posts // Request 2013 posts
$this->requestURL($controller, 'first-post/archive/2013'); $this->requestURL($controller, 'first-post/archive/2013');
$this->assertIDsEquals( $this->assertIDsEquals(
array($firstPostID, $secondPostID, $secondFuturePostID), [$firstPostID, $secondPostID, $secondFuturePostID],
$controller->PaginatedList() $controller->PaginatedList()
); );
} }