You are here

public function ConfigSplitEntityListBuilder::getDefaultOperations in Configuration Split 8

Same name and namespace in other branches
  1. 2.0.x 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 80

Class

ConfigSplitEntityListBuilder
Provides a listing of Configuration Split setting entities.

Namespace

Drupal\config_split

Code

public function getDefaultOperations(EntityInterface $entity) {

  /** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity */
  $operations = parent::getDefaultOperations($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'),
    ];
  }
  return $operations;
}