diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index 7712bf1..32e3dc5 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -634,4 +634,11 @@ public function initTranslation($langcode) { // http://drupal.org/node/2004244 } + /** + * {@inheritdoc} + */ + public function getOperationLinks() { + return array(); + } + } diff --git a/core/lib/Drupal/Core/Entity/EntityBCDecorator.php b/core/lib/Drupal/Core/Entity/EntityBCDecorator.php index 52d3f6f..e9b1844 100644 --- a/core/lib/Drupal/Core/Entity/EntityBCDecorator.php +++ b/core/lib/Drupal/Core/Entity/EntityBCDecorator.php @@ -624,5 +624,11 @@ public function removeTranslation($langcode) { public function initTranslation($langcode) { $this->decorated->initTranslation($langcode); } + /** + * {@inheritdoc} + */ + public function getOperationLinks() { + return $this->decorated->getOperationLinks(); + } } diff --git a/core/lib/Drupal/Core/Entity/EntityInterface.php b/core/lib/Drupal/Core/Entity/EntityInterface.php index cdb4cd3..20bbe42 100644 --- a/core/lib/Drupal/Core/Entity/EntityInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityInterface.php @@ -334,4 +334,11 @@ public function isTranslatable(); */ public function initTranslation($langcode); + /** + * 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 6efda89..6a219bd 100644 --- a/core/modules/block/lib/Drupal/block/BlockBase.php +++ b/core/modules/block/lib/Drupal/block/BlockBase.php @@ -224,4 +224,12 @@ public function submit($form, &$form_state) { * @see \Drupal\block\BlockBase::submit() */ public function blockSubmit($form, &$form_state) {} + + /** + * {@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 cf049a5..a41dd0c 100644 --- a/core/modules/block/lib/Drupal/block/BlockInterface.php +++ b/core/modules/block/lib/Drupal/block/BlockInterface.php @@ -22,4 +22,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 6a5a2ed..818a283 100644 --- a/core/modules/block/lib/Drupal/block/BlockListController.php +++ b/core/modules/block/lib/Drupal/block/BlockListController.php @@ -174,6 +174,7 @@ public function buildForm(array $form, array &$form_state) { 'no_striping' => TRUE, ), ); + $form['blocks'][$region]['title'] = array( '#markup' => $region != BLOCK_REGION_NONE ? $title : t('Disabled'), '#wrapper_attributes' => array( @@ -190,6 +191,7 @@ public function buildForm(array $form, array &$form_state) { ), ), ); + $form['blocks'][$region . '-message']['message'] = array( '#markup' => '' . t('No blocks in this region') . '', '#wrapper_attributes' => array( @@ -240,14 +242,16 @@ public function buildForm(array $form, array &$form_state) { 'class' => array('block-weight', 'block-weight-' . $region), ), ); + $links = array(); $links['configure'] = array( - 'title' => t('configure'), + 'title' => t('Configure'), 'href' => 'admin/structure/block/manage/' . $entity_id . '/configure', ); $links['delete'] = array( - 'title' => t('delete'), + 'title' => t('Delete'), 'href' => 'admin/structure/block/manage/' . $entity_id . '/delete', ); + $links += $entities[$entity_id]->getOperationLinks(); $form['blocks'][$entity_id]['operations'] = array( '#type' => 'operations', '#links' => $links, diff --git a/core/modules/block/lib/Drupal/block/BlockPluginInterface.php b/core/modules/block/lib/Drupal/block/BlockPluginInterface.php index 1887816..4247dcd 100644 --- a/core/modules/block/lib/Drupal/block/BlockPluginInterface.php +++ b/core/modules/block/lib/Drupal/block/BlockPluginInterface.php @@ -102,4 +102,11 @@ public function submit($form, &$form_state); */ public function build(); + /** + * Returns a list of operation links available for this block. + * + * @return array + */ + public function getOperationLinks(); + } 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 1d3cca8..2827275 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 @@ -172,4 +172,13 @@ public function preSave(EntityStorageControllerInterface $storage_controller) { $this->set('settings', $this->getPlugin()->getConfig()); } + /** + * {@inheritdoc} + */ + public function getOperationLinks() { + $plugin = $this->getPlugin(); + $links = $plugin->getOperationLinks(); + 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 8e7879e..8aef210 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/Block/SystemMenuBlock.php +++ b/core/modules/system/lib/Drupal/system/Plugin/Block/SystemMenuBlock.php @@ -10,6 +10,9 @@ use Drupal\block\BlockBase; use Drupal\Component\Annotation\Plugin; use Drupal\Core\Annotation\Translation; +use Drupal\Core\Entity\EntityStorageControllerInterface; +use Drupal\Core\Plugin\ContainerFactoryPluginInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Provides a 'System 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/system/lib/Drupal/system/Plugin/Core/Entity/Menu.php b/core/modules/system/lib/Drupal/system/Plugin/Core/Entity/Menu.php index f12e2a6..a5648e2 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 @@ -60,4 +60,16 @@ class Menu extends ConfigEntityBase implements MenuInterface { */ public $description; + /** + * {@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/views_ui/lib/Drupal/views_ui/ViewUI.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php index 92fa27b..897cb58 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php @@ -1243,4 +1243,12 @@ public function mergeDefaultDisplaysOptions() { public function uriRelationships() { return $this->storage->uriRelationships(); } + + /** + * {@inheritdoc} + */ + public function getOperationLinks() { + return $this->storage->getOperationLinks(); + } + }