class LocalTaskListBuilder

Provides the views data for the message entity type.

Hierarchy

  • class \Drupal\tmgmt_local\Entity\ListBuilder\LocalTaskListBuilder extends \Drupal\Core\Entity\EntityListBuilder

Expanded class hierarchy of LocalTaskListBuilder

File

translators/tmgmt_local/src/Entity/ListBuilder/LocalTaskListBuilder.php, line 12

Namespace

Drupal\tmgmt_local\Entity\ListBuilder
View source
class LocalTaskListBuilder extends EntityListBuilder {

  /**
   * {@inheritdoc}
   */
  protected function getDefaultOperations(EntityInterface $entity) {
    $operations = parent::getDefaultOperations($entity);

    /** @var \Drupal\tmgmt_local\Entity\LocalTask $entity */
    if ($entity
      ->access('view')) {
      $operations['view'] = array(
        'title' => $this
          ->t('View'),
        'weight' => -10,
        // Backwards compatibility with Drupal <8.5, which does not yet
        // provide ensureDestination().
        'url' => method_exists($this, 'ensureDestination') ? $this
          ->ensureDestination($entity
          ->toUrl('canonical')) : $entity
          ->toUrl('canonical'),
      );
    }
    if (\Drupal::currentUser()
      ->hasPermission('administer translation tasks') && tmgmt_local_translation_access($entity) && $entity
      ->getStatus() == LocalTaskInterface::STATUS_UNASSIGNED) {
      $operations['assign'] = array(
        'title' => $this
          ->t('Assign'),
        'weight' => 0,
        'url' => $entity
          ->toUrl('assign'),
      );
    }
    elseif (tmgmt_local_translation_access($entity) && $entity
      ->getStatus() == LocalTaskInterface::STATUS_UNASSIGNED) {
      $operations['assign_to_me'] = array(
        'title' => $this
          ->t('Assign to me'),
        'weight' => 0,
        'url' => $entity
          ->toUrl('assign_to_me'),
      );
    }
    if ($entity
      ->getStatus() != LocalTaskInterface::STATUS_UNASSIGNED && $entity
      ->access('unassign')) {
      $operations['unassign'] = array(
        'title' => $this
          ->t('Unassign'),
        'weight' => 0,
        'url' => $entity
          ->toUrl('unassign'),
      );
    }
    return $operations;
  }

}

Members