Skip to content

Commit

Permalink
Merge branch '1' into 2
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Aug 31, 2022
2 parents 809ca2d + 9308bfe commit ec1111f
Show file tree
Hide file tree
Showing 27 changed files with 413 additions and 207 deletions.
8 changes: 4 additions & 4 deletions code/AdminRootController.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ public static function admin_url()
public static function rules()
{
if (self::$adminRules === null) {
self::$adminRules = array();
self::$adminRules = [];

// Map over the array calling add_rule_for_controller on each
$classes = CMSMenu::get_cms_classes(null, true, CMSMenu::URL_PRIORITY);
array_map(array(__CLASS__, 'add_rule_for_controller'), $classes ?? []);
array_map([__CLASS__, 'add_rule_for_controller'], $classes ?? []);
}
return self::$adminRules;
}
Expand Down Expand Up @@ -135,8 +135,8 @@ public function handleRequest(HTTPRequest $request)
*/
public static function get_template_global_variables()
{
return array(
return [
'adminURL' => 'admin_url'
);
];
}
}
12 changes: 6 additions & 6 deletions code/CMSBatchAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ public function response($successMessage, $status)
* }
* }
*/
public function batchaction(SS_List $objs, $helperMethod, $successMessage, $arguments = array())
public function batchaction(SS_List $objs, $helperMethod, $successMessage, $arguments = [])
{
$status = array('modified' => array(), 'error' => array(), 'deleted' => array(), 'success' => array());
$status = ['modified' => [], 'error' => [], 'deleted' => [], 'success' => []];

foreach ($objs as $obj) {
// Perform the action
$id = $obj->ID;
if (!call_user_func_array(array($obj, $helperMethod), $arguments ?? [])) {
if (!call_user_func_array([$obj, $helperMethod], $arguments ?? [])) {
$status['error'][$id] = $id;
} else {
$status['success'][$id] = $id;
Expand All @@ -115,9 +115,9 @@ public function batchaction(SS_List $objs, $helperMethod, $successMessage, $argu
// Now make sure the tree title is appropriately updated
$publishedRecord = DataObject::get_by_id($this->managedClass, $id);
if ($publishedRecord) {
$status['modified'][$id] = array(
$status['modified'][$id] = [
'TreeTitle' => $publishedRecord->TreeTitle,
);
];
} else {
$status['deleted'][$id] = $id;
}
Expand Down Expand Up @@ -148,7 +148,7 @@ public function applicablePagesHelper($ids, $methodName, $checkStagePages = true
user_error("Bad \$methodName passed to applicablePagesHelper()", E_USER_WARNING);
}

$applicableIDs = array();
$applicableIDs = [];

$managedClass = $this->managedClass;
$draftPages = DataObject::get($managedClass)->byIDs($ids);
Expand Down
18 changes: 9 additions & 9 deletions code/CMSBatchActionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class CMSBatchActionHandler extends RequestHandler
{

/** @config */
private static $batch_actions = array();
private static $batch_actions = [];

/**
* List of registered actions
Expand All @@ -34,17 +34,17 @@ class CMSBatchActionHandler extends RequestHandler
*/
private static $registered_actions = null;

private static $url_handlers = array(
private static $url_handlers = [
'$BatchAction/applicablepages' => 'handleApplicablePages',
'$BatchAction/confirmation' => 'handleConfirmation',
'$BatchAction' => 'handleBatchAction',
);
];

private static $allowed_actions = array(
private static $allowed_actions = [
'handleBatchAction',
'handleApplicablePages',
'handleConfirmation',
);
];

/**
* @var Controller
Expand Down Expand Up @@ -178,7 +178,7 @@ public function handleApplicablePages($request)
if ($ids) {
$applicableIDs = $actionHandler->applicablePages($ids);
} else {
$applicableIDs = array();
$applicableIDs = [];
}

$response = new HTTPResponse(json_encode($applicableIDs));
Expand Down Expand Up @@ -206,7 +206,7 @@ public function handleConfirmation($request)
if ($actionHandler->hasMethod('confirmationDialog')) {
$response = new HTTPResponse(json_encode($actionHandler->confirmationDialog($ids)));
} else {
$response = new HTTPResponse(json_encode(array('alert' => false)));
$response = new HTTPResponse(json_encode(['alert' => false]));
}

$response->addHeader("Content-type", "application/json");
Expand Down Expand Up @@ -246,10 +246,10 @@ public function batchActionList()
foreach ($actions as $urlSegment => $action) {
$actionObj = $this->buildAction($action['class']);
if ($actionObj->canView()) {
$actionDef = new ArrayData(array(
$actionDef = new ArrayData([
"Link" => Controller::join_links($this->Link(), $urlSegment),
"Title" => $actionObj->getActionTitle(),
));
]);
$actionList->push($actionDef);
}
}
Expand Down
24 changes: 12 additions & 12 deletions code/CMSMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class CMSMenu implements IteratorAggregate, i18nEntityProvider
* - array('type' => 'add', 'item' => CMSMenuItem::create(...) )
* - array('type' => 'remove', 'code' => 'codename' )
*/
protected static $menu_item_changes = array();
protected static $menu_item_changes = [];

/**
* Set to true if clear_menu() is called, to indicate that the default menu shouldn't be
Expand Down Expand Up @@ -200,7 +200,7 @@ public static function get_menu_code($cmsClass)
*/
public static function get_menu_items()
{
$menuItems = array();
$menuItems = [];

// Set up default menu items
if (!self::$menu_is_cleared) {
Expand Down Expand Up @@ -231,8 +231,8 @@ public static function get_menu_items()
}

// Sort menu items according to priority, then title asc
$menuPriority = array();
$menuTitle = array();
$menuPriority = [];
$menuTitle = [];
foreach ($menuItems as $key => $menuItem) {
$menuPriority[$key] = is_numeric($menuItem->priority) ? $menuItem->priority : 0;
$menuTitle[$key] = $menuItem->title;
Expand All @@ -255,7 +255,7 @@ public static function get_viewable_menu_items($member = null)
$member = Security::getCurrentUser();
}

$viewableMenuItems = array();
$viewableMenuItems = [];
$allMenuItems = self::get_menu_items();
if ($allMenuItems) {
foreach ($allMenuItems as $code => $menuItem) {
Expand Down Expand Up @@ -287,7 +287,7 @@ public static function get_viewable_menu_items($member = null)
*/
public static function remove_menu_item($code)
{
self::$menu_item_changes[] = array('type' => 'remove', 'code' => $code);
self::$menu_item_changes[] = ['type' => 'remove', 'code' => $code];
}

/**
Expand All @@ -306,7 +306,7 @@ public static function remove_menu_class($className)
*/
public static function clear_menu()
{
self::$menu_item_changes = array();
self::$menu_item_changes = [];
self::$menu_is_cleared = true;
}

Expand Down Expand Up @@ -342,11 +342,11 @@ public static function replace_menu_item(
$item->setAttributes($attributes);
}

self::$menu_item_changes[] = array(
self::$menu_item_changes[] = [
'type' => 'add',
'code' => $code,
'item' => $item,
);
];
}

/**
Expand All @@ -357,11 +357,11 @@ public static function replace_menu_item(
*/
protected static function add_menu_item_obj($code, $cmsMenuItem)
{
self::$menu_item_changes[] = array(
self::$menu_item_changes[] = [
'type' => 'add',
'code' => $code,
'item' => $cmsMenuItem,
);
];
}

/**
Expand Down Expand Up @@ -428,7 +428,7 @@ public function getIterator()
public function provideI18nEntities()
{
$cmsClasses = self::get_cms_classes();
$entities = array();
$entities = [];
foreach ($cmsClasses as $cmsClass) {
$defaultTitle = LeftAndMain::menu_title($cmsClass, false);
$ownerModule = ClassLoader::inst()->getManifest()->getOwnerModule($cmsClass);
Expand Down
4 changes: 2 additions & 2 deletions code/CMSMenuItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class CMSMenuItem
*
* @var string
*/
protected $attributes = array();
protected $attributes = [];

/**
* @var string
Expand Down Expand Up @@ -105,7 +105,7 @@ public function getAttributesHTML($attrs = null)
}

// Create markkup
$parts = array();
$parts = [];

foreach ($attrs as $name => $value) {
if ($value === true) {
Expand Down
2 changes: 1 addition & 1 deletion code/CMSProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,6 @@ public function save($data, $form)
public function Breadcrumbs($unlinked = false)
{
$items = parent::Breadcrumbs($unlinked);
return new ArrayList(array($items[0]));
return new ArrayList([$items[0]]);
}
}
4 changes: 2 additions & 2 deletions code/Forms/UsedOnTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,12 @@ public function setRecord($record)
*/
public function getAttributes()
{
$attributes = array(
$attributes = [
'class' => $this->extraClass(),
'id' => $this->ID(),
'data-schema' => json_encode($this->getSchemaData()),
'data-state' => json_encode($this->getSchemaState()),
);
];

$attributes = array_merge($attributes, $this->attributes);

Expand Down
12 changes: 6 additions & 6 deletions code/GroupImportForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function __construct($controller, $name, $fields = null, $actions = null,
. 'cleared.</li>'
. '</ul>'
. '</div>',
array('columns' => $columns)
['columns' => $columns]
);

$fields = new FieldList(
Expand All @@ -63,7 +63,7 @@ public function __construct($controller, $name, $fields = null, $actions = null,
))
)
);
$fileField->getValidator()->setAllowedExtensions(array('csv'));
$fileField->getValidator()->setAllowedExtensions(['csv']);
}

if (!$actions) {
Expand All @@ -90,26 +90,26 @@ public function doImport($data, $form)
$result = $loader->load($data['CsvFile']['tmp_name']);

// result message
$msgArr = array();
$msgArr = [];
if ($result->CreatedCount()) {
$msgArr[] = _t(
__CLASS__ . '.ResultCreated',
'Created {count} groups',
array('count' => $result->CreatedCount())
['count' => $result->CreatedCount()]
);
}
if ($result->UpdatedCount()) {
$msgArr[] = _t(
__CLASS__ . '.ResultUpdated',
'Updated {count} groups',
array('count' => $result->UpdatedCount())
['count' => $result->UpdatedCount()]
);
}
if ($result->DeletedCount()) {
$msgArr[] = _t(
__CLASS__ . '.ResultDeleted',
'Deleted {count} groups',
array('count' => $result->DeletedCount())
['count' => $result->DeletedCount()]
);
}
$msg = ($msgArr) ? implode(',', $msgArr) : _t('SilverStripe\\Admin\\MemberImportForm.ResultNone', 'No changes');
Expand Down
Loading

0 comments on commit ec1111f

Please sign in to comment.