public function WorkspaceListBuilder::getDefaultOperations in Workspace 8.2
Same name and namespace in other branches
- 8 src/WorkspaceListBuilder.php \Drupal\workspace\WorkspaceListBuilder::getDefaultOperations()
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
- src/
WorkspaceListBuilder.php, line 79
Class
- WorkspaceListBuilder
- Defines a class to build a listing of workspace entities.
Namespace
Drupal\workspaceCode
public function getDefaultOperations(EntityInterface $entity) {
/** @var \Drupal\workspace\WorkspaceInterface $entity */
$operations = parent::getDefaultOperations($entity);
if (isset($operations['edit'])) {
$operations['edit']['query']['destination'] = $entity
->toUrl('collection')
->toString();
}
$active_workspace = $this->workspaceManager
->getActiveWorkspace();
if ($entity
->id() != $active_workspace
->id()) {
$operations['activate'] = [
'title' => $this
->t('Set Active'),
// Use a weight lower than the one of the 'Edit' operation because we
// want the 'Activate' operation to be the primary operation.
'weight' => 0,
'url' => $entity
->toUrl('activate-form', [
'query' => [
'destination' => $entity
->toUrl('collection')
->toString(),
],
]),
];
}
if (!$entity
->getRepositoryHandler() instanceof NullRepositoryHandler) {
$operations['deploy'] = [
'title' => $this
->t('Deploy content'),
// The 'Deploy' operation should be the default one for the currently
// active workspace.
'weight' => $entity
->id() == $active_workspace
->id() ? 0 : 20,
'url' => $entity
->toUrl('deploy-form', [
'query' => [
'destination' => $entity
->toUrl('collection')
->toString(),
],
]),
];
}
return $operations;
}