public function ConfigSplitEntityListBuilder::getDefaultOperations in Configuration Split 2.0.x
Same name and namespace in other branches
- 8 src/ConfigSplitEntityListBuilder.php \Drupal\config_split\ConfigSplitEntityListBuilder::getDefaultOperations()
Gets this list's default operations.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity the operations are for.
Return value
array The array structure is identical to the return value of self::getOperations().
Overrides ConfigEntityListBuilder::getDefaultOperations
File
- src/
ConfigSplitEntityListBuilder.php, line 98
Class
- ConfigSplitEntityListBuilder
- Provides a listing of Configuration Split setting entities.
Namespace
Drupal\config_splitCode
public function getDefaultOperations(EntityInterface $entity) {
/** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity */
$operations = parent::getDefaultOperations($entity);
// Operations changing the entity.
if (!$entity
->get('status') && $entity
->hasLinkTemplate('enable')) {
$operations['enable'] = [
'title' => $this
->t('Enable'),
'weight' => 40,
'url' => $entity
->toUrl('enable'),
];
}
elseif ($entity
->hasLinkTemplate('disable')) {
$operations['disable'] = [
'title' => $this
->t('Disable'),
'weight' => 50,
'url' => $entity
->toUrl('disable'),
];
}
// Operations changing the site config.
$config = $this->configFactory
->get('config_split.config_split.' . $entity
->id());
$enforced = $this->statusOverride
->getSettingsOverride($entity
->id()) !== NULL;
if ($config
->get('status')) {
if ($entity
->hasLinkTemplate('import')) {
$operations['import'] = [
'title' => $this
->t('Import'),
'weight' => 40,
'url' => $entity
->toUrl('import'),
];
}
if ($entity
->hasLinkTemplate('export')) {
$operations['export'] = [
'title' => $this
->t('Export'),
'weight' => 40,
'url' => $entity
->toUrl('export'),
];
}
if ($entity
->hasLinkTemplate('deactivate') && !$enforced) {
$operations['deactivate'] = [
'title' => $this
->t('Deactivate'),
'weight' => 40,
'url' => $entity
->toUrl('deactivate'),
];
}
}
else {
if ($entity
->get('storage') === 'collection') {
if ($entity
->hasLinkTemplate('activate') && !$enforced) {
$operations['activate'] = [
'title' => $this
->t('Activate'),
'weight' => 40,
'url' => $entity
->toUrl('activate'),
];
}
if ($entity
->hasLinkTemplate('import') && !$enforced) {
$operations['import'] = [
'title' => $this
->t('Import'),
'weight' => 40,
'url' => $entity
->toUrl('import'),
];
}
}
else {
if ($entity
->hasLinkTemplate('import') && !$enforced) {
$operations['import'] = [
'title' => $this
->t('Activate/Import'),
'weight' => 40,
'url' => $entity
->toUrl('import'),
];
}
}
}
return $operations;
}