You are here

public function AnalyticsServiceListBuilder::getDefaultOperations in Analytics 8

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/AnalyticsServiceListBuilder.php, line 63

Class

AnalyticsServiceListBuilder
Provides a listing of analytics instances.

Namespace

Drupal\analytics

Code

public function getDefaultOperations(EntityInterface $entity) {

  /** @var \Drupal\analytics\Entity\AnalyticsServiceInterface $entity */
  $operations = parent::getDefaultOperations($entity);
  if (!$entity
    ->get('status') && $entity
    ->hasLinkTemplate('enable')) {
    $operations['enable'] = [
      'title' => t('Enable'),
      'weight' => 40,
      'url' => $entity
        ->toUrl('enable'),
    ];
  }
  elseif ($entity
    ->hasLinkTemplate('disable')) {
    $operations['disable'] = [
      'title' => t('Disable'),
      'weight' => 50,
      'url' => $entity
        ->toUrl('disable'),
    ];
  }
  return $operations;
}