diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index 2e4a7ea..b8b8509 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -399,4 +399,11 @@ protected function routeProvider() { return $this->routeProvider; } + /** + * {@inheritdoc} + */ + public function getOperationLinks() { + return array(); + } + } diff --git a/core/lib/Drupal/Core/Entity/EntityInterface.php b/core/lib/Drupal/Core/Entity/EntityInterface.php index b9f1d5e..2423db0 100644 --- a/core/lib/Drupal/Core/Entity/EntityInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityInterface.php @@ -240,4 +240,11 @@ public function referencedEntities(); */ public function changed(); + /** + * Returns a list of operation links available for this entity. + * + * @return array + */ + public function getOperationLinks(); + } diff --git a/core/modules/block/lib/Drupal/block/BlockBase.php b/core/modules/block/lib/Drupal/block/BlockBase.php index 48e469b..8ae61c8 100644 --- a/core/modules/block/lib/Drupal/block/BlockBase.php +++ b/core/modules/block/lib/Drupal/block/BlockBase.php @@ -185,4 +185,11 @@ public function getMachineNameSuggestion() { return $transliterated; } + /** + * {@inheritdoc} + */ + public function getOperationLinks() { + return array(); + } + } diff --git a/core/modules/block/lib/Drupal/block/BlockInterface.php b/core/modules/block/lib/Drupal/block/BlockInterface.php index de0d9de..ed5622a 100644 --- a/core/modules/block/lib/Drupal/block/BlockInterface.php +++ b/core/modules/block/lib/Drupal/block/BlockInterface.php @@ -32,4 +32,11 @@ */ public function getPlugin(); + /** + * Returns a list of operation links available for this entity. + * + * @return array + */ + public function getOperationLinks(); + } diff --git a/core/modules/block/lib/Drupal/block/BlockListController.php b/core/modules/block/lib/Drupal/block/BlockListController.php index 8547ba4..1416e83 100644 --- a/core/modules/block/lib/Drupal/block/BlockListController.php +++ b/core/modules/block/lib/Drupal/block/BlockListController.php @@ -386,6 +386,8 @@ public function getOperations(EntityInterface $entity) { $operations['edit']['title'] = t('Configure'); } + $operations += $entity->getOperationLinks(); + return $operations; } diff --git a/core/modules/block/lib/Drupal/block/BlockPluginInterface.php b/core/modules/block/lib/Drupal/block/BlockPluginInterface.php index 047efd9..36f0b87 100644 --- a/core/modules/block/lib/Drupal/block/BlockPluginInterface.php +++ b/core/modules/block/lib/Drupal/block/BlockPluginInterface.php @@ -126,4 +126,11 @@ public function blockSubmit($form, &$form_state); */ public function getMachineNameSuggestion(); + /** + * Returns a list of operation links available for this block. + * + * @return array + */ + public function getOperationLinks(); + } diff --git a/core/modules/block/lib/Drupal/block/Entity/Block.php b/core/modules/block/lib/Drupal/block/Entity/Block.php index 926ef07..c9f3f6f 100644 --- a/core/modules/block/lib/Drupal/block/Entity/Block.php +++ b/core/modules/block/lib/Drupal/block/Entity/Block.php @@ -176,4 +176,13 @@ public static function sort($a, $b) { return strcmp($a->label(), $b->label()); } + /** + * {@inheritdoc} + */ + public function getOperationLinks() { + $plugin = $this->getPlugin(); + $links = $plugin->getOperationLinks(); + return $links; + } + } diff --git a/core/modules/system/lib/Drupal/system/Entity/Menu.php b/core/modules/system/lib/Drupal/system/Entity/Menu.php index fa5d7fd..d88af1f 100644 --- a/core/modules/system/lib/Drupal/system/Entity/Menu.php +++ b/core/modules/system/lib/Drupal/system/Entity/Menu.php @@ -88,4 +88,16 @@ public function isLocked() { return (bool) $this->locked; } + /** + * {@inheritdoc} + */ + public function getOperationLinks() { + $links = parent::getOperationLinks(); + if (\Drupal::currentUser()->hasPermission('administer menu')) { + $links['menu-edit']['href'] = 'admin/structure/menu/manage/' . $this->id(); + $links['menu-edit']['title'] = t('Edit menu'); + } + return $links; + } + } diff --git a/core/modules/system/lib/Drupal/system/Plugin/Block/SystemMenuBlock.php b/core/modules/system/lib/Drupal/system/Plugin/Block/SystemMenuBlock.php index 8298193..a315cec 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/Block/SystemMenuBlock.php +++ b/core/modules/system/lib/Drupal/system/Plugin/Block/SystemMenuBlock.php @@ -9,6 +9,9 @@ use Drupal\block\BlockBase; use Drupal\Core\Session\AccountInterface; +use Drupal\Core\Entity\EntityStorageControllerInterface; +use Drupal\Core\Plugin\ContainerFactoryPluginInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Provides a generic Menu block. @@ -30,4 +33,19 @@ public function build() { return menu_tree($menu); } + /** + * {@inheritdoc} + */ + public function getOperationLinks() { + // @todo Clean up when http://drupal.org/node/1874498 lands. + list(, $menu) = explode(':', $this->getPluginId()); + + $links = array(); + if (user_access('administer menu')) { + $links['menu-edit']['href'] = 'admin/structure/menu/manage/' . $menu; + $links['menu-edit']['title'] = t('Edit menu'); + } + return $links; + } + } diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php index ea6448c..9d11fb8 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php @@ -1171,4 +1171,11 @@ public function changed() { return $this->storage->changed(); } + /** + * {@inheritdoc} + */ + public function getOperationLinks() { + return $this->storage->getOperationLinks(); + } + }