public function ThemeSwitcherRuleListBuilder::buildRow in Theme Switcher Rules 8
Builds a row for an entity in the entity listing.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity for this row of the list.
Return value
array A render array structure of fields for this entity.
Overrides DraggableListBuilder::buildRow
See also
\Drupal\Core\Entity\EntityListBuilder::render()
File
- src/
Controller/ ThemeSwitcherRuleListBuilder.php, line 116
Class
- ThemeSwitcherRuleListBuilder
- Provides a listing of theme_switcher_rule.
Namespace
Drupal\theme_switcher\ControllerCode
public function buildRow(EntityInterface $entity) {
$row['label'] = $entity
->label();
$row['machine_name'] = [
'#markup' => $entity
->id(),
];
$not_set = '<i>- None -</i>';
$row['theme'] = [
'#markup' => empty($entity
->getTheme()) ? $not_set : $entity
->getTheme(),
];
$row['admin_theme'] = [
'#markup' => empty($entity
->getAdminTheme()) ? $not_set : $entity
->getAdminTheme(),
];
$row['status'] = [
'#markup' => $entity
->status() ? $this
->t('Active') : $this
->t('Inactive'),
'#prefix' => $entity
->status() ? '<strong>' : '',
'#suffix' => $entity
->status() ? '</strong>' : '',
];
$row += parent::buildRow($entity);
// Only super-admins may sort switch theme rules.
if (!$this->currentUser
->hasPermission('administer theme switcher rules')) {
unset($row['weight']);
}
return $row;
}