diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index 785c81c..c1719da 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -450,4 +450,11 @@ public function isTranslatable() { return !empty($bundles[$this->bundle()]['translatable']); } + /** + * Implements \Drupal\Core\Entity\EntityInterface::getOperationLinks(). + */ + public function getOperationLinks() { + return array(); + } + } diff --git a/core/lib/Drupal/Core/Entity/EntityBCDecorator.php b/core/lib/Drupal/Core/Entity/EntityBCDecorator.php index 08be87c..cf7d86c 100644 --- a/core/lib/Drupal/Core/Entity/EntityBCDecorator.php +++ b/core/lib/Drupal/Core/Entity/EntityBCDecorator.php @@ -468,4 +468,11 @@ public function isTranslatable() { return $this->decorated->isTranslatable(); } + /** + * Implements \Drupal\Core\Entity\EntityInterface::getOperationLinks(). + */ + public function getOperationLinks() { + return array(); + } + } diff --git a/core/lib/Drupal/Core/Entity/EntityInterface.php b/core/lib/Drupal/Core/Entity/EntityInterface.php index b900490..8f611a2 100644 --- a/core/lib/Drupal/Core/Entity/EntityInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityInterface.php @@ -228,4 +228,11 @@ public function getOriginalEntity(); */ public function isTranslatable(); + /** + * 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 4de2a59..ca558fe 100644 --- a/core/modules/block/lib/Drupal/block/BlockBase.php +++ b/core/modules/block/lib/Drupal/block/BlockBase.php @@ -496,4 +496,11 @@ public function submit($form, &$form_state) { */ public function blockSubmit($form, &$form_state) {} + /** + * Implements \Drupal\block\BlockInterface::getOperationLinks(). + */ + 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 65bdee3..a3d2e4a 100644 --- a/core/modules/block/lib/Drupal/block/BlockInterface.php +++ b/core/modules/block/lib/Drupal/block/BlockInterface.php @@ -102,4 +102,11 @@ public function submit($form, &$form_state); */ public function build(); + /** + * 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 5dd981f..99606bd 100644 --- a/core/modules/block/lib/Drupal/block/BlockListController.php +++ b/core/modules/block/lib/Drupal/block/BlockListController.php @@ -159,6 +159,7 @@ public function buildForm(array $form, array &$form_state) { '#title' => t('Region for @block block', array('@block' => $info['admin_label'])), '#options' => $this->regions, ); + $links = array(); $links['configure'] = array( 'title' => t('configure'), 'href' => 'admin/structure/block/manage/' . $entity_id . '/configure', @@ -167,6 +168,7 @@ public function buildForm(array $form, array &$form_state) { 'title' => t('delete'), 'href' => 'admin/structure/block/manage/' . $entity_id . '/delete', ); + $links += $entity->getOperationLinks(); $form['blocks'][$entity_id]['operations'] = array( '#type' => 'operations', '#links' => $links, 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 077a81e..e5d6e81 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 @@ -198,4 +198,14 @@ public function getExportProperties() { return $properties; } + /** + * Implements \Drupal\Core\Entity\EntityInterface::getOperationLinks(). + */ + public function getOperationLinks() { + $plugin = $this->getPlugin(); + $links = $plugin->getOperationLinks(); + return $links; + } + + } diff --git a/core/modules/menu/lib/Drupal/menu/Plugin/block/block/MenuBlock.php b/core/modules/menu/lib/Drupal/menu/Plugin/block/block/MenuBlock.php index c535fc6..f6cd614 100644 --- a/core/modules/menu/lib/Drupal/menu/Plugin/block/block/MenuBlock.php +++ b/core/modules/menu/lib/Drupal/menu/Plugin/block/block/MenuBlock.php @@ -31,4 +31,18 @@ public function build() { return menu_tree($menu); } + /** + * Implements \Drupal\block\BlockInterface::getOperationLinks(). + */ + public function getOperationLinks() { + $links = array(); + if (user_access('administer menu')) { + list(, $menu) = explode(':', $this->getPluginId(), '2'); + list(, $menu) = explode('-', $menu, 2); + $links['menu-edit']['href'] = 'admin/structure/menu/manage/' . $menu . '/edit'; + $links['menu-edit']['title'] = t('Edit menu'); + } + return $links; + } + } diff --git a/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemMenuBlock.php b/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemMenuBlock.php index 01aa470..cd91641 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemMenuBlock.php +++ b/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemMenuBlock.php @@ -42,4 +42,18 @@ public function build() { return menu_tree($menu); } + /** + * Implements \Drupal\block\BlockInterface::getOperationLinks(). + */ + public function getOperationLinks() { + $links = array(); + if (user_access('administer menu')) { + list(, $menu) = explode(':', $this->getPluginId(), '2'); + list(, $menu) = explode('-', $menu, 2); + $links['menu-edit']['href'] = 'admin/structure/menu/manage/' . $menu . '/edit'; + $links['menu-edit']['title'] = t('Edit menu'); + } + return $links; + } + }