LocalTaskListBuilder.php in Translation Management Tool 8        
                          
                  
                        
  
  
  
  
  
File
  translators/tmgmt_local/src/Entity/ListBuilder/LocalTaskListBuilder.php
  
    View source  
  <?php
namespace Drupal\tmgmt_local\Entity\ListBuilder;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityListBuilder;
use Drupal\tmgmt_local\LocalTaskInterface;
class LocalTaskListBuilder extends EntityListBuilder {
  
  protected function getDefaultOperations(EntityInterface $entity) {
    $operations = parent::getDefaultOperations($entity);
    
    if ($entity
      ->access('view')) {
      $operations['view'] = array(
        'title' => $this
          ->t('View'),
        'weight' => -10,
        
        '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;
  }
}