protected function LocalTaskListBuilder::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/ LocalTaskListBuilder.php, line 17
Class
- LocalTaskListBuilder
- Provides the views data for the message entity type.
Namespace
Drupal\tmgmt_local\Entity\ListBuilderCode
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;
}