You are here

protected function LocalTaskItemListBuilder::getDefaultOperations in Translation Management Tool 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 EntityListBuilder::getDefaultOperations

File

translators/tmgmt_local/src/Entity/ListBuilder/LocalTaskItemListBuilder.php, line 16

Class

LocalTaskItemListBuilder
Provides the views data for the message entity type.

Namespace

Drupal\tmgmt_local\Entity\ListBuilder

Code

protected function getDefaultOperations(EntityInterface $entity) {

  /** @var \Drupal\tmgmt_local\Entity\LocalTaskItem $entity */
  $operations = parent::getDefaultOperations($entity);
  if ($entity
    ->access('view', \Drupal::currentUser()) && $entity
    ->getTask()
    ->getAssignee() && $entity
    ->getTask()
    ->getAssignee()
    ->id() == \Drupal::currentUser()
    ->id()) {
    if ($entity
      ->isPending()) {
      $operations['translate'] = [
        'url' => $entity
          ->toUrl(),
        'title' => t('Translate'),
        'weight' => 0,
      ];
    }
    else {
      $operations['view'] = [
        'url' => $entity
          ->toUrl(),
        'title' => t('View'),
        'weight' => 0,
      ];
    }
  }
  return $operations;
}