Commit a13df3e3 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

🚑 fix(management) Avoid a lot of array_merge on empty arrays

parent badd6873
......@@ -143,9 +143,8 @@ class Action
);
}
function getRowClasses(ListingEntry $entry)
function fillRowClasses(&$classes, ListingEntry $entry)
{
return array();
}
function renderColumnIcons(ListingEntry $entry)
......
......@@ -464,15 +464,11 @@ class management
return $result;
}
function getActionRowClasses(ListingEntry $entry)
function fillActionRowClasses(&$classes, ListingEntry $entry)
{
$classes = array();
foreach ($this->actions as $action) {
// TODO optimize
$classes = array_merge($classes, $action->getRowClasses($entry));
$action->fillRowClasses($classes, $entry);
}
return $classes;
}
/*!
......
......@@ -168,7 +168,7 @@ class managementListing
'props' => $column->getHtmlCellProps(),
'render' => $column->renderCell($entry)
);
$row['classes'] = array_merge($row['classes'], $column->getRowClasses($entry));
$column->fillRowClasses($row['classes'], $entry);
}
$row['index'] = $entry->row;
......
......@@ -28,9 +28,9 @@ class ActionsColumn extends Column
return FALSE;
}
function getRowClasses(ListingEntry $entry)
function fillRowClasses(&$classes, ListingEntry $entry)
{
return $this->parent->parent->getActionRowClasses($entry);
$this->parent->parent->fillActionRowClasses($classes, $entry);
}
function renderCell(ListingEntry $entry)
......
......@@ -100,9 +100,8 @@ class Column
}
}
function getRowClasses(ListingEntry $entry)
function fillRowClasses(&$classes, ListingEntry $entry)
{
return array();
}
function renderCell(ListingEntry $entry)
......
......@@ -68,13 +68,10 @@ class LockAction extends Action
);
}
function getRowClasses(ListingEntry $entry)
function fillRowClasses(&$classes, ListingEntry $entry)
{
$lockStatus = $this->isLocked($entry);
if ($lockStatus === TRUE) {
return array('entry-locked');
} else {
return array();
if ($this->isLocked($entry) === TRUE) {
$classes[] = 'entry-locked';
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment