diff --git a/core/includes/entity.api.php b/core/includes/entity.api.php index 148f11d..de052a7 100644 --- a/core/includes/entity.api.php +++ b/core/includes/entity.api.php @@ -589,3 +589,15 @@ function hook_entity_field_access_alter(array &$grants, array $context) { $grants['node'] = NULL; } } + +/** + * Alters an entity's operations links. + * + * @param \Drupal\Core\Entity\EntityInterface $entity + * @param array $operations + * The format is identical to that of theme_links()'s $variables['links] + * parameter. + */ +function hook_entity_operations_alter(EntityInterface $entity, array $operations) { + unset($operations['disable']); +} diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityListController.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityListController.php index c4fa043..54d62a8 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityListController.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityListController.php @@ -24,33 +24,4 @@ public function load() { return $entities; } - /** - * Overrides \Drupal\Core\Entity\EntityListController::getOperations(); - */ - public function getOperations(EntityInterface $entity) { - $operations = parent::getOperations($entity); - $uri = $entity->uri(); - - if (isset($this->entityInfo['entity_keys']['status'])) { - if (!$entity->status()) { - $operations['enable'] = array( - 'title' => t('Enable'), - 'href' => $uri['path'] . '/enable', - 'options' => $uri['options'], - 'weight' => -10, - ); - } - else { - $operations['disable'] = array( - 'title' => t('Disable'), - 'href' => $uri['path'] . '/disable', - 'options' => $uri['options'], - 'weight' => 20, - ); - } - } - - return $operations; - } - } diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityOperationsController.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityOperationsController.php new file mode 100644 index 0000000..dd3587c --- /dev/null +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityOperationsController.php @@ -0,0 +1,48 @@ +uri(); + + if ($entity instanceof ConfigEntityInterface) { + if (!$entity->status()) { + $operations['enable'] = array( + 'title' => t('Enable'), + 'href' => $uri['path'] . '/enable', + 'options' => $uri['options'], + 'weight' => -10, + ); + } + else { + $operations['disable'] = array( + 'title' => t('Disable'), + 'href' => $uri['path'] . '/disable', + 'options' => $uri['options'], + 'weight' => 20, + ); + } + } + + return $operations; + } + +} diff --git a/core/lib/Drupal/Core/Entity/EntityDefaultsOperationsController.php b/core/lib/Drupal/Core/Entity/EntityDefaultsOperationsController.php new file mode 100644 index 0000000..91567b7 --- /dev/null +++ b/core/lib/Drupal/Core/Entity/EntityDefaultsOperationsController.php @@ -0,0 +1,123 @@ +entityType = $entity_type; + $this->entityInfo = entity_get_info($entity_type); + $this->moduleHandler = $module_handler; + } + + /** + * {@inheritdoc} + */ + public function getOwnOperations(EntityInterface $entity) { + $uri = $entity->uri(); + $operations = array(); + $operations['edit'] = array( + 'title' => t('Edit'), + 'href' => $uri['path'] . '/edit', + 'options' => $uri['options'], + 'weight' => 10, + ); + $operations['delete'] = array( + 'title' => t('Delete'), + 'href' => $uri['path'] . '/delete', + 'options' => $uri['options'], + 'weight' => 100, + ); + return $operations; + } + + /** + * {@inheritdoc} + */ + public function getOperations(EntityInterface $entity) { + $operations = $this->getOwnOperations($entity); + + // Apply access checking. + foreach ($operations as $key => $operation) { + if (!$entity->access($key)) { + unset($operations[$key]); + } + } + + $this->moduleHandler->alter(array('entity_operations', $entity->entityType() . '_operations'), $entity, $operations); + + return $operations; + } +} diff --git a/core/lib/Drupal/Core/Entity/EntityListController.php b/core/lib/Drupal/Core/Entity/EntityListController.php index 354b27a..d319a7d 100644 --- a/core/lib/Drupal/Core/Entity/EntityListController.php +++ b/core/lib/Drupal/Core/Entity/EntityListController.php @@ -7,6 +7,8 @@ namespace Drupal\Core\Entity; +use Symfony\Component\HttpFoundation\Request; + /** * Provides a generic implementation of an entity list controller. */ @@ -20,6 +22,13 @@ class EntityListController implements EntityListControllerInterface { protected $storage; /** + * The entity operations controller class. + * + * @var \Drupal\Core\Entity\EntityOperationsControllerInterface + */ + protected $operations; + + /** * The entity type name. * * @var string @@ -42,11 +51,14 @@ class EntityListController implements EntityListControllerInterface { * The type of entity to be listed. * @param \Drupal\Core\Entity\EntityStorageControllerInterface $storage. * The entity storage controller class. + * @param \Drupal\Core\Entity\EntityOperationsControllerInterface $operations + * The entity operations controller class. */ - public function __construct($entity_type, EntityStorageControllerInterface $storage) { + public function __construct($entity_type, EntityStorageControllerInterface $storage, EntityOperationsControllerInterface $operations) { $this->entityType = $entity_type; $this->storage = $storage; $this->entityInfo = entity_get_info($this->entityType); + $this->operations = $operations; } /** @@ -64,23 +76,10 @@ public function load() { } /** - * Implements \Drupal\Core\Entity\EntityListControllerInterface::getOperations(). + * {@inheritdoc} */ public function getOperations(EntityInterface $entity) { - $uri = $entity->uri(); - $operations['edit'] = array( - 'title' => t('Edit'), - 'href' => $uri['path'] . '/edit', - 'options' => $uri['options'], - 'weight' => 10, - ); - $operations['delete'] = array( - 'title' => t('Delete'), - 'href' => $uri['path'] . '/delete', - 'options' => $uri['options'], - 'weight' => 100, - ); - return $operations; + return $this->operations->getOperations($entity); } /** @@ -131,6 +130,8 @@ public function buildRow(EntityInterface $entity) { public function buildOperations(EntityInterface $entity) { // Retrieve and sort operations. $operations = $this->getOperations($entity); + + uasort($operations, 'drupal_sort_weight'); $build = array( '#type' => 'operations', diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index 9e1d12f..95a6f07 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -142,7 +142,7 @@ public function getStorageController($entity_type) { public function getListController($entity_type) { if (!isset($this->controllers['listing'][$entity_type])) { $class = $this->getControllerClass($entity_type, 'list'); - $this->controllers['listing'][$entity_type] = new $class($entity_type, $this->getStorageController($entity_type)); + $this->controllers['listing'][$entity_type] = new $class($entity_type, $this->getStorageController($entity_type), $this->getOperationsController($entity_type)); } return $this->controllers['listing'][$entity_type]; } @@ -201,6 +201,22 @@ public function getAccessController($entity_type) { } /** + * Creates a new operations controller instance. + */ + public function getOperationsController($entity_type) { + if (!isset($this->controllers['operations'][$entity_type])) { + $class = $this->getControllerClass($entity_type, 'operations'); + if (in_array('Drupal\Core\Entity\EntityControllerInterface', class_implements($class))) { + $this->controllers['operations'][$entity_type] = $class::createInstance($this->container, $entity_type, $this->getDefinition($entity_type)); + } + else { + $this->controllers['operations'][$entity_type] = new $class($entity_type, $this->container->get('module_handler'), $this->container->get('router.route_provider'), $this->container->get('router'), $this->container->get('access_manager')); + } + } + return $this->controllers['operations'][$entity_type]; + } + + /** * Returns the administration path for an entity type's bundle. * * @param string $entity_type diff --git a/core/lib/Drupal/Core/Entity/EntityOperationsControllerInterface.php b/core/lib/Drupal/Core/Entity/EntityOperationsControllerInterface.php new file mode 100644 index 0000000..9c95c29 --- /dev/null +++ b/core/lib/Drupal/Core/Entity/EntityOperationsControllerInterface.php @@ -0,0 +1,37 @@ +uri(); + $operations['manage-fields'] = array( + 'title' => t('Manage fields'), + 'href' => $uri['path'] . '/fields', + 'options' => $uri['options'], + 'weight' => 15, + ); + $operations['manage-display'] = array( + 'title' => t('Manage display'), + 'href' => $uri['path'] . '/display', + 'options' => $uri['options'], + 'weight' => 20, + ); + } + return $operations; + } + +} diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlockType.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlockType.php index e4d3ab2..9db63c8 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlockType.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlockType.php @@ -24,7 +24,8 @@ * "form" = { * "default" = "Drupal\custom_block\CustomBlockTypeFormController" * }, - * "list" = "Drupal\custom_block\CustomBlockTypeListController" + * "list" = "Drupal\custom_block\CustomBlockTypeListController", + * "operations" = "Drupal\custom_block\CustomBlockOperationsController" * }, * config_prefix = "custom_block.type", * entity_keys = { diff --git a/core/modules/block/lib/Drupal/block/Plugin/Core/Entity/Block.php b/core/modules/block/lib/Drupal/block/Plugin/Core/Entity/Block.php index 3c8b14c..6cb9eea 100644 --- a/core/modules/block/lib/Drupal/block/Plugin/Core/Entity/Block.php +++ b/core/modules/block/lib/Drupal/block/Plugin/Core/Entity/Block.php @@ -25,6 +25,7 @@ * "access" = "Drupal\block\BlockAccessController", * "render" = "Drupal\block\BlockRenderController", * "list" = "Drupal\block\BlockListController", + * "operations" = "Drupal\Core\Config\Entity\ConfigEntityOperationsController", * "form" = { * "default" = "Drupal\block\BlockFormController" * } diff --git a/core/modules/contact/lib/Drupal/contact/CategoryListController.php b/core/modules/contact/lib/Drupal/contact/CategoryListController.php index a3ec886..617fa93 100644 --- a/core/modules/contact/lib/Drupal/contact/CategoryListController.php +++ b/core/modules/contact/lib/Drupal/contact/CategoryListController.php @@ -15,29 +15,6 @@ class CategoryListController extends ConfigEntityListController { /** - * Overrides Drupal\Core\Entity\EntityListController::getOperations(). - */ - public function getOperations(EntityInterface $entity) { - $operations = parent::getOperations($entity); - if (module_exists('field_ui')) { - $uri = $entity->uri(); - $operations['manage-fields'] = array( - 'title' => t('Manage fields'), - 'href' => $uri['path'] . '/fields', - 'options' => $uri['options'], - 'weight' => 11, - ); - $operations['manage-display'] = array( - 'title' => t('Manage display'), - 'href' => $uri['path'] . '/display', - 'options' => $uri['options'], - 'weight' => 12, - ); - } - return $operations; - } - - /** * Overrides Drupal\Core\Entity\EntityListController::buildHeader(). */ public function buildHeader() { diff --git a/core/modules/contact/lib/Drupal/contact/CategoryOperationsController.php b/core/modules/contact/lib/Drupal/contact/CategoryOperationsController.php new file mode 100644 index 0000000..0ea7fbc --- /dev/null +++ b/core/modules/contact/lib/Drupal/contact/CategoryOperationsController.php @@ -0,0 +1,41 @@ +uri(); + $operations['manage-fields'] = array( + 'title' => t('Manage fields'), + 'href' => $uri['path'] . '/fields', + 'options' => $uri['options'], + 'weight' => 11, + ); + $operations['manage-display'] = array( + 'title' => t('Manage display'), + 'href' => $uri['path'] . '/display', + 'options' => $uri['options'], + 'weight' => 12, + ); + } + return $operations; + } + +} diff --git a/core/modules/contact/lib/Drupal/contact/Plugin/Core/Entity/Category.php b/core/modules/contact/lib/Drupal/contact/Plugin/Core/Entity/Category.php index 7e068da..65e5f59 100644 --- a/core/modules/contact/lib/Drupal/contact/Plugin/Core/Entity/Category.php +++ b/core/modules/contact/lib/Drupal/contact/Plugin/Core/Entity/Category.php @@ -24,7 +24,8 @@ * "list" = "Drupal\contact\CategoryListController", * "form" = { * "default" = "Drupal\contact\CategoryFormController" - * } + * }, + * "operations" = "Drupal\contact\CategoryOperationsController" * }, * uri_callback = "contact_category_uri", * config_prefix = "contact.category", diff --git a/core/modules/menu/lib/Drupal/menu/MenuListController.php b/core/modules/menu/lib/Drupal/menu/MenuListController.php index e557d92..7916430 100644 --- a/core/modules/menu/lib/Drupal/menu/MenuListController.php +++ b/core/modules/menu/lib/Drupal/menu/MenuListController.php @@ -41,32 +41,6 @@ public function buildRow(EntityInterface $entity) { } /** - * Overrides \Drupal\Core\Entity\EntityListController::getOperations(); - */ - public function getOperations(EntityInterface $entity) { - $operations = parent::getOperations($entity); - $uri = $entity->uri(); - - $operations['edit']['title'] = t('Edit menu'); - $operatuins['edit']['href'] = $uri['path']; - $operations['add'] = array( - 'title' => t('Add link'), - 'href' => $uri['path'] . '/add', - 'options' => $uri['options'], - 'weight' => 20, - ); - // System menus could not be deleted. - $system_menus = menu_list_system_menus(); - if (isset($system_menus[$entity->id()])) { - unset($operations['delete']); - } - else { - $operations['delete']['title'] = t('Delete menu'); - } - return $operations; - } - - /** * Overrides \Drupal\Core\Entity\EntityListController::render(); */ public function render() { diff --git a/core/modules/menu/lib/Drupal/menu/MenuOperationsController.php b/core/modules/menu/lib/Drupal/menu/MenuOperationsController.php new file mode 100644 index 0000000..8b60afe --- /dev/null +++ b/core/modules/menu/lib/Drupal/menu/MenuOperationsController.php @@ -0,0 +1,46 @@ +uri(); + + $operations['edit']['title'] = t('Edit menu'); + $operations['edit']['href'] = $uri['path']; + $operations['add'] = array( + 'title' => t('Add link'), + 'href' => $uri['path'] . '/add', + 'options' => $uri['options'], + 'weight' => 20, + ); + // System menus could not be deleted. + $system_menus = menu_list_system_menus(); + if (isset($system_menus[$entity->id()])) { + unset($operations['delete']); + } + else { + $operations['delete']['title'] = t('Delete menu'); + } + return $operations; + } + + +} diff --git a/core/modules/picture/lib/Drupal/picture/PictureMappingListController.php b/core/modules/picture/lib/Drupal/picture/PictureMappingListController.php index 343dbd3..bec0b8b 100644 --- a/core/modules/picture/lib/Drupal/picture/PictureMappingListController.php +++ b/core/modules/picture/lib/Drupal/picture/PictureMappingListController.php @@ -31,19 +31,4 @@ public function hookMenu() { return $items; } - /** - * Overrides Drupal\config\ConfigEntityListController::getOperations(); - */ - public function getOperations(EntityInterface $entity) { - $operations = parent::getOperations($entity); - $uri = $entity->uri(); - $operations['duplicate'] = array( - 'title' => t('Duplicate'), - 'href' => $uri['path'] . '/duplicate', - 'options' => $uri['options'], - 'weight' => 15, - ); - return $operations; - } - } diff --git a/core/modules/picture/lib/Drupal/picture/PictureOperationsController.php b/core/modules/picture/lib/Drupal/picture/PictureOperationsController.php new file mode 100644 index 0000000..70b8702 --- /dev/null +++ b/core/modules/picture/lib/Drupal/picture/PictureOperationsController.php @@ -0,0 +1,34 @@ +uri(); + $operations['duplicate'] = array( + 'title' => t('Duplicate'), + 'href' => $uri['path'] . '/duplicate', + 'options' => $uri['options'], + 'weight' => 15, + ); + return $operations; + } + +} diff --git a/core/modules/picture/lib/Drupal/picture/Plugin/Core/Entity/PictureMapping.php b/core/modules/picture/lib/Drupal/picture/Plugin/Core/Entity/PictureMapping.php index 887dddf..e3a8198 100644 --- a/core/modules/picture/lib/Drupal/picture/Plugin/Core/Entity/PictureMapping.php +++ b/core/modules/picture/lib/Drupal/picture/Plugin/Core/Entity/PictureMapping.php @@ -26,7 +26,8 @@ * "edit" = "Drupal\picture\PictureMappingFormController", * "add" = "Drupal\picture\PictureMappingFormController", * "duplicate" = "Drupal\picture\PictureMappingFormController" - * } + * }, + * "operations" = "Drupal\picture\PictureOperationsController" * }, * list_path = "admin/config/media/picturemapping", * uri_callback = "picture_mapping_uri", diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Plugin/Core/Entity/Shortcut.php b/core/modules/shortcut/lib/Drupal/shortcut/Plugin/Core/Entity/Shortcut.php index 95802d8..dd60999 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Plugin/Core/Entity/Shortcut.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Plugin/Core/Entity/Shortcut.php @@ -26,7 +26,8 @@ * "form" = { * "default" = "Drupal\shortcut\ShortcutFormController", * "edit" = "Drupal\shortcut\ShortcutFormController" - * } + * }, + * "operations" = "Drupal\shortcut\ShortcutOperationsController" * }, * config_prefix = "shortcut.set", * entity_keys = { diff --git a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutListController.php b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutListController.php index f1aaa60..1cb1088 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutListController.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutListController.php @@ -24,32 +24,6 @@ public function buildHeader() { } /** - * Overrides \Drupal\Core\Entity\EntityListController::getOperations(). - */ - public function getOperations(EntityInterface $entity) { - $uri = $entity->uri(); - $operations['list'] = array( - 'title' => t('List links'), - 'href' => $uri['path'], - ); - $operations['edit'] = array( - 'title' => t('Edit set'), - 'href' => $uri['path'] . '/edit', - 'options' => $uri['options'], - 'weight' => 10, - ); - if ($entity->access('delete')) { - $operations['delete'] = array( - 'title' => t('Delete set'), - 'href' => $uri['path'] . '/delete', - 'options' => $uri['options'], - 'weight' => 100, - ); - } - return $operations; - } - - /** * Overrides \Drupal\Core\Entity\EntityListController::buildRow(). */ public function buildRow(EntityInterface $entity) { diff --git a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutOperationsController.php b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutOperationsController.php new file mode 100644 index 0000000..1923035 --- /dev/null +++ b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutOperationsController.php @@ -0,0 +1,44 @@ +uri(); + $operations['list'] = array( + 'title' => t('List links'), + 'href' => $uri['path'], + ); + $operations['edit'] = array( + 'title' => t('Edit set'), + 'href' => $uri['path'] . '/edit', + 'options' => $uri['options'], + 'weight' => 10, + ); + if ($entity->access('delete')) { + $operations['delete'] = array( + 'title' => t('Delete set'), + 'href' => $uri['path'] . '/delete', + 'options' => $uri['options'], + 'weight' => 100, + ); + } + return $operations; + } + +} diff --git a/core/modules/system/lib/Drupal/system/Plugin/Core/Entity/Menu.php b/core/modules/system/lib/Drupal/system/Plugin/Core/Entity/Menu.php index f12e2a6..090b1ff 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/Core/Entity/Menu.php +++ b/core/modules/system/lib/Drupal/system/Plugin/Core/Entity/Menu.php @@ -20,7 +20,8 @@ * label = @Translation("Menu"), * module = "system", * controllers = { - * "storage" = "Drupal\Core\Config\Entity\ConfigStorageController" + * "storage" = "Drupal\Core\Config\Entity\ConfigStorageController", + * "operations" = "Drupal\menu\MenuOperationsController" * }, * config_prefix = "menu.menu", * entity_keys = { diff --git a/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/Role.php b/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/Role.php index 5a288c8..7446254 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/Role.php +++ b/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/Role.php @@ -23,6 +23,7 @@ * "storage" = "Drupal\user\RoleStorageController", * "access" = "Drupal\user\RoleAccessController", * "list" = "Drupal\user\RoleListController", + * "operations" = "Drupal\user\RoleOperationsController", * "form" = { * "default" = "Drupal\user\RoleFormController" * } diff --git a/core/modules/user/lib/Drupal/user/RoleListController.php b/core/modules/user/lib/Drupal/user/RoleListController.php index 9ff5c83..7390d97 100644 --- a/core/modules/user/lib/Drupal/user/RoleListController.php +++ b/core/modules/user/lib/Drupal/user/RoleListController.php @@ -37,24 +37,6 @@ public function buildHeader() { /** * {@inheritdoc} */ - public function getOperations(EntityInterface $entity) { - $operations = parent::getOperations($entity); - - $operations['permissions'] = array( - 'title' => t('Edit permissions'), - 'href' => 'admin/people/permissions/' . $entity->id(), - 'weight' => 20, - ); - // Built-in roles could not be deleted or disabled. - if (in_array($entity->id(), array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID))) { - unset($operations['delete']); - } - return $operations; - } - - /** - * {@inheritdoc} - */ public function buildRow(EntityInterface $entity) { $row = parent::buildRow($entity); diff --git a/core/modules/user/lib/Drupal/user/RoleOperationsController.php b/core/modules/user/lib/Drupal/user/RoleOperationsController.php new file mode 100644 index 0000000..0f3f1a5 --- /dev/null +++ b/core/modules/user/lib/Drupal/user/RoleOperationsController.php @@ -0,0 +1,38 @@ + t('Edit permissions'), + 'href' => 'admin/people/permissions/' . $entity->id(), + 'weight' => 20, + // @todo No route yet. + ); + // Built-in roles could not be deleted or disabled. + if (in_array($entity->id(), array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID))) { + unset($operations['delete']); + } + return $operations; + } + + +} diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewListController.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewListController.php index 7bb130e..fdfcb96 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewListController.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewListController.php @@ -82,30 +82,6 @@ public function buildHeader() { } /** - * Implements \Drupal\Core\Entity\EntityListController::getOperations(). - */ - public function getOperations(EntityInterface $view) { - $definition = parent::getOperations($view); - $uri = $view->uri(); - - $definition['clone'] = array( - 'title' => t('Clone'), - 'href' => $uri['path'] . '/clone', - 'options' => $uri['options'], - 'weight' => 15, - ); - - // Add AJAX functionality to enable/disable operations. - foreach (array('enable', 'disable') as $op) { - if (isset($definition[$op])) { - $definition[$op]['ajax'] = TRUE; - } - } - - return $definition; - } - - /** * Overrides Drupal\Core\Entity\EntityListController::buildOperations(); */ public function buildOperations(EntityInterface $entity) { diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewOperationsController.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewOperationsController.php new file mode 100644 index 0000000..a930d22 --- /dev/null +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewOperationsController.php @@ -0,0 +1,42 @@ +uri(); + + $operations['clone'] = array( + 'title' => t('Clone'), + 'href' => $uri['path'] . '/clone', + 'options' => $uri['options'], + 'weight' => 15, + ); + + // Add AJAX functionality to enable/disable operations. + foreach (array('enable', 'disable') as $op) { + if (isset($operations[$op])) { + $operations[$op]['ajax'] = TRUE; + } + } + + return $operations; + } + +} diff --git a/core/modules/views_ui/views_ui.module b/core/modules/views_ui/views_ui.module index 0d461be..e0878fd 100644 --- a/core/modules/views_ui/views_ui.module +++ b/core/modules/views_ui/views_ui.module @@ -110,6 +110,7 @@ function views_ui_entity_info(&$entity_info) { 'preview' => 'Drupal\views_ui\ViewPreviewFormController', 'clone' => 'Drupal\views_ui\ViewCloneFormController', ), + 'operations' => 'Drupal\views_ui\ViewOperationsController' ); }