public function WorkspaceListBuilder::getDefaultOperations in Workspace 8
Same name and namespace in other branches
- 8.2 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 76
Class
- WorkspaceListBuilder
- Defines a class to build a listing of workspace entities.
Namespace
Drupal\workspaceCode
public function getDefaultOperations(EntityInterface $entity) {
/** @var \Drupal\multiversion\Entity\WorkspaceInterface $entity */
$operations = parent::getDefaultOperations($entity);
if (isset($operations['edit'])) {
$operations['edit']['query']['destination'] = $entity
->toUrl('collection')
->toString();
}
$active_workspace = $this->workspaceManager
->getActiveWorkspaceId();
if ($entity
->id() != $active_workspace) {
$operations['activate'] = [
'title' => $this
->t('Set Active'),
'weight' => 20,
'url' => $entity
->toUrl('activate-form', [
'query' => [
'destination' => $entity
->toUrl('collection')
->toString(),
],
]),
];
}
$operations['changes'] = [
'title' => $this
->t('View Changes'),
'weight' => 21,
'url' => $entity
->toUrl('changes', [
'workspace' => $entity
->id(),
]),
];
$operations['conflicts'] = [
'title' => $this
->t('View Conflicts'),
'weight' => 22,
'url' => $entity
->toUrl('conflicts', [
'workspace' => $entity
->id(),
]),
];
return $operations;
}