Skip to content

Commit

Permalink
FIX updated traditional array syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
Franco Springveldt committed Sep 13, 2017
1 parent d9d5c01 commit e70e051
Show file tree
Hide file tree
Showing 23 changed files with 182 additions and 182 deletions.
8 changes: 4 additions & 4 deletions src/Admin/GridFieldCategorisationConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ public function __construct($itemsPerPage = 15, $mergeRecords, $parentType, $par
$columns = $this->getComponentByType('SilverStripe\\Forms\\GridField\\GridFieldDataColumns');

$columns->setFieldFormatting(
array(
[
'BlogPostsCount' => function ($value, CategorisationObject $item) {
return $item->BlogPosts()->Count();
}
)
]
);

$this->changeColumnOrder();
Expand All @@ -57,12 +57,12 @@ protected function changeColumnOrder()
$columns = $this->getComponentByType('SilverStripe\\Forms\\GridField\\GridFieldDataColumns');

$columns->setDisplayFields(
array(
[
'Title' => 'Title',
'BlogPostsCount' => 'Posts',
'MergeAction' => 'MergeAction',
'Actions' => 'Actions'
)
]
);
}
}
2 changes: 1 addition & 1 deletion src/Admin/GridFieldFormAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class GridFieldFormAction extends GridField_FormAction
/**
* @var array
*/
protected $extraAttributes = array();
protected $extraAttributes = [];

/**
* @param array $attributes
Expand Down
18 changes: 9 additions & 9 deletions src/Admin/GridFieldMergeAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class GridFieldMergeAction implements GridField_ColumnProvider, GridField_Action
* @param string $parentMethod
* @param string $childMethod
*/
public function __construct($records = array(), $parentType, $parentMethod, $childMethod)
public function __construct($records = [], $parentType, $parentMethod, $childMethod)
{
$this->records = $records;
$this->parentType = $parentType;
Expand All @@ -70,7 +70,7 @@ public function augmentColumns($gridField, &$columns)
*/
public function getColumnsHandled($gridField)
{
return array('MergeAction');
return ['MergeAction'];
}

/**
Expand All @@ -88,15 +88,15 @@ public function getColumnContent($gridField, $record, $columnName)
'MergeAction' . $record->ID,
'Move',
'merge',
array(
[
'record' => $record->ID,
'target' => $prefix . '-target-record-' . $record->ID,
)
]
);

$action->setExtraAttributes(array(
$action->setExtraAttributes([
'data-target' => $prefix . '-target-record-' . $record->ID
));
]);

return $dropdown->Field() . $action->Field() . '<a title="Move posts to" class="MergeActionReveal">move posts to</a>';
}
Expand All @@ -109,23 +109,23 @@ public function getColumnContent($gridField, $record, $columnName)
*/
public function getColumnAttributes($gridField, $record, $columnName)
{
return array('class' => 'MergeAction');
return ['class' => 'MergeAction'];
}

/**
* {@inheritdoc}
*/
public function getColumnMetadata($gridField, $columnName)
{
return array('title' => 'Move posts to');
return ['title' => 'Move posts to'];
}

/**
* {@inheritdoc}
*/
public function getActions($gridField)
{
return array('merge');
return ['merge'];
}

/**
Expand Down
16 changes: 8 additions & 8 deletions src/Forms/GridField/GridFieldAddByDBField.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ public function __construct($targetFragment = 'before', $dataObjectField = 'Titl
*/
public function getActions($gridField)
{
return array(
return [
'add',
);
];
}

/**
Expand Down Expand Up @@ -94,9 +94,9 @@ public function handleAction(GridField $gridField, $actionName, $arguments, $dat
__CLASS__ . '.AddFail',
'Unable to save {class} to the database.',
'Unable to add the DataObject.',
array(
[
'class' => get_class($obj),
)
]
)
);
}
Expand All @@ -107,9 +107,9 @@ public function handleAction(GridField $gridField, $actionName, $arguments, $dat
__CLASS__ . '.PermissionFail',
'You don\'t have permission to create a {class}.',
'Unable to add the DataObject.',
array(
[
'class' => get_class($obj)
)
]
)
);
}
Expand Down Expand Up @@ -198,12 +198,12 @@ public function getHTMLFragments($gridField)
$addAction->setAttribute('data-icon', 'add');
$addAction->addExtraClass('btn btn-primary');

$forTemplate = new ArrayData(array());
$forTemplate = new ArrayData([]);

$forTemplate->Fields = new ArrayList();
$forTemplate->Fields->push($textField);
$forTemplate->Fields->push($addAction);

return array($this->targetFragment => $forTemplate->renderWith(self::class));
return [$this->targetFragment => $forTemplate->renderWith(self::class)];
}
}
22 changes: 11 additions & 11 deletions src/Forms/GridField/GridFieldBlogPostState.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public function getColumnContent($gridField, $record, $columnName)
__CLASS__ . '.Draft',
'<i class="btn-icon gridfield-icon btn-icon-pencil"></i> Saved as Draft on {date}',
'State for when a post is saved.',
array(
[
'date' => $lastEdited->FormatFromSettings(),
)
]
);
}

Expand All @@ -51,22 +51,22 @@ public function getColumnContent($gridField, $record, $columnName)

if (strtotime($record->PublishDate) > time()) {
return _t(
__CLASS__ . '.Timer',
__CLASS__ . '.Timer',
'<i class="gridfield-icon blog-icon-timer"></i> Publish at {date}',
'State for when a post is published.',
array(
[
'date' => $publishDate->FormatFromSettings(),
)
]
) . $modifiedLabel;
}

return _t(
__CLASS__ . '.Published',
__CLASS__ . '.Published',
'<i class="btn-icon gridfield-icon btn-icon-accept"></i> Published on {date}',
'State for when a post is published.',
array(
[
'date' => $publishDate->FormatFromSettings(),
)
]
) . $modifiedLabel;
}
}
Expand All @@ -91,12 +91,12 @@ public function getColumnAttributes($gridField, $record, $columnName)
$class = 'gridfield-icon published';
}

return array(
return [
'class' => $class,
);
];
}
}

return array();
return [];
}
}
42 changes: 21 additions & 21 deletions src/Model/Blog.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,48 +87,48 @@ class Blog extends Page implements PermissionProvider
/**
* @var array
*/
private static $db = array(
private static $db = [
'PostsPerPage' => 'Int',
);
];

/**
* @var array
*/
private static $has_many = array(
private static $has_many = [
'Tags' => BlogTag::class,
'Categories' => BlogCategory::class,
);
];

/**
* @var array
*/
private static $many_many = array(
private static $many_many = [
'Editors' => Member::class,
'Writers' => Member::class,
'Contributors' => Member::class,
);
];

/**
* @var array
*/
private static $allowed_children = array(
private static $allowed_children = [
BlogPost::class,
);
];

/**
* @var array
*/
private static $extensions = array(
private static $extensions = [
BlogFilter::class,
);
];

/**
* @var array
*/
private static $defaults = array(
private static $defaults = [
'ProvideComments' => false,
'PostsPerPage' => 10
);
];

/**
* @var string
Expand Down Expand Up @@ -182,10 +182,10 @@ public function getCMSFields()
*/
$fields->addFieldsToTab(
'Root.Categorisation',
array(
[
$categories,
$tags
)
]
);

$fields->findOrMakeTab('Root.Categorisation')->addExtraClass('blog-cms-categorisation');
Expand Down Expand Up @@ -408,11 +408,11 @@ public function getSettingsFields()

$fields->addFieldsToTab(
'Root.Users',
array(
[
$editorField,
$writerField,
$contributorField
)
]
);

return $fields;
Expand Down Expand Up @@ -606,8 +606,8 @@ public function getLumberjackGridFieldConfig()
*/
public function providePermissions()
{
return array(
Blog::MANAGE_USERS => array(
return [
Blog::MANAGE_USERS => [
'name' => _t(
__CLASS__ . '.PERMISSION_MANAGE_USERS_DESCRIPTION',
'Manage users for individual blogs'
Expand All @@ -618,8 +618,8 @@ public function providePermissions()
),
'category' => _t(__CLASS__ . '.PERMISSIONS_CATEGORY', 'Blog permissions'),
'sort' => 100
)
);
]
];
}

/**
Expand All @@ -644,7 +644,7 @@ protected function assignGroup()

// Must check if the method exists or else an error occurs when changing page type
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) {
if (!$user->inGroup($group)) {
$user->Groups()->add($group);
Expand Down
12 changes: 6 additions & 6 deletions src/Model/BlogCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,24 @@ class BlogCategory extends DataObject implements CategorisationObject
/**
* @var array
*/
private static $db = array(
private static $db = [
'Title' => 'Varchar(255)',
'URLSegment' => 'Varchar(255)'
);
];

/**
* @var array
*/
private static $has_one = array(
private static $has_one = [
'Blog' => Blog::class,
);
];

/**
* @var array
*/
private static $belongs_many_many = array(
private static $belongs_many_many = [
'BlogPosts' => BlogPost::class,
);
];

/**
* {@inheritdoc}
Expand Down
Loading

0 comments on commit e70e051

Please sign in to comment.