diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index 9d20fb9..3cd7279 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -369,4 +369,11 @@ public function changed() { } } + /** + * {@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 f02bb1e..6186446 100644 --- a/core/lib/Drupal/Core/Entity/EntityInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityInterface.php @@ -245,4 +245,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 a602ab9..20fc4fc 100644 --- a/core/modules/block/lib/Drupal/block/BlockBase.php +++ b/core/modules/block/lib/Drupal/block/BlockBase.php @@ -180,4 +180,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 874ff35..3139325 100644 --- a/core/modules/block/lib/Drupal/block/BlockListController.php +++ b/core/modules/block/lib/Drupal/block/BlockListController.php @@ -384,6 +384,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 f433ea6..5b3cb32 100644 --- a/core/modules/block/lib/Drupal/block/Entity/Block.php +++ b/core/modules/block/lib/Drupal/block/Entity/Block.php @@ -172,4 +172,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 5f6d075..b4e118e 100644 --- a/core/modules/system/lib/Drupal/system/Entity/Menu.php +++ b/core/modules/system/lib/Drupal/system/Entity/Menu.php @@ -90,4 +90,16 @@ public function isLocked() { return (bool) $this->locked; } + /** + * {@inheritdoc} + */ + public function getOperationLinks() { + $links = parent::getOperationLinks(); + if (user_access('administer menu')) { + $links['menu-edit']['href'] = 'admin/structure/menu/manage/' . $this->id() . '/edit'; + $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 c983672..48d225d 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/Block/SystemMenuBlock.php +++ b/core/modules/system/lib/Drupal/system/Plugin/Block/SystemMenuBlock.php @@ -11,6 +11,9 @@ use Drupal\block\Annotation\Block; use Drupal\Core\Annotation\Translation; 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. @@ -42,4 +45,18 @@ public function build() { return menu_tree($menu); } + /** + * {@inheritdoc} + */ + public function getOperationLinks() { + list(, $menu) = explode(':', $this->getPluginId()); + + $links = array(); + if (user_access('administer menu')) { + $links['menu-edit']['href'] = 'admin/structure/menu/manage/' . $menu . '/edit'; + $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 84bfde1..91bf433 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php @@ -1169,4 +1169,11 @@ public function changed() { return $this->storage->changed(); } + /** + * {@inheritdoc} + */ + public function getOperationLinks() { + return $this->storage->getOperationLinks(); + } + }