summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2013-11-27 20:02:40 (GMT)
committerNathaniel Catchpole2013-11-27 20:02:40 (GMT)
commit66f8fb82533b9e4b1076226d298395d82a126881 (patch)
tree9d9b63f819619f67c7ca0e2bf19f90f8d56eccad
parent14bf431e6b06bb147b3c306858e3b39e54269967 (diff)
Issue #2102369 by vijaycs85, JeroenT, ACF, rteijeiro, -enzo-, tim.plunkett: Remove drupal_set_title in custom block module controllers and entitylist controllers.
-rw-r--r--core/lib/Drupal/Core/Entity/EntityListController.php12
-rw-r--r--core/modules/block/custom_block/custom_block.routing.yml2
-rw-r--r--core/modules/block/custom_block/lib/Drupal/custom_block/Controller/CustomBlockController.php20
-rw-r--r--core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php3
-rw-r--r--core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeListController.php6
5 files changed, 32 insertions, 11 deletions
diff --git a/core/lib/Drupal/Core/Entity/EntityListController.php b/core/lib/Drupal/Core/Entity/EntityListController.php
index 0a722a0..64c1c43 100644
--- a/core/lib/Drupal/Core/Entity/EntityListController.php
+++ b/core/lib/Drupal/Core/Entity/EntityListController.php
@@ -202,6 +202,7 @@ class EntityListController implements EntityListControllerInterface, EntityContr
$build = array(
'#theme' => 'table',
'#header' => $this->buildHeader(),
+ '#title' => $this->getTitle(),
'#rows' => array(),
'#empty' => $this->t('There is no @label yet.', array('@label' => $this->entityInfo['label'])),
);
@@ -249,4 +250,15 @@ class EntityListController implements EntityListControllerInterface, EntityContr
return $this;
}
+ /**
+ * Returns the title of the page.
+ *
+ * @return string
+ * A string title of the page.
+ *
+ */
+ protected function getTitle() {
+ return;
+ }
+
}
diff --git a/core/modules/block/custom_block/custom_block.routing.yml b/core/modules/block/custom_block/custom_block.routing.yml
index f395409..622d08d 100644
--- a/core/modules/block/custom_block/custom_block.routing.yml
+++ b/core/modules/block/custom_block/custom_block.routing.yml
@@ -9,6 +9,7 @@ custom_block.add_page:
path: '/block/add'
defaults:
_content: 'Drupal\custom_block\Controller\CustomBlockController::add'
+ _title: 'Add custom block'
requirements:
_permission: 'administer blocks'
@@ -16,6 +17,7 @@ custom_block.add_form:
path: '/block/add/{custom_block_type}'
defaults:
_content: 'Drupal\custom_block\Controller\CustomBlockController::addForm'
+ _title_callback: 'Drupal\custom_block\Controller\CustomBlockController::getAddFormTitle'
requirements:
_permission: 'administer blocks'
diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Controller/CustomBlockController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Controller/CustomBlockController.php
index 1bcfa20..6469baf 100644
--- a/core/modules/block/custom_block/lib/Drupal/custom_block/Controller/CustomBlockController.php
+++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Controller/CustomBlockController.php
@@ -8,13 +8,14 @@
namespace Drupal\custom_block\Controller;
use Drupal\Component\Plugin\PluginManagerInterface;
+use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Entity\EntityStorageControllerInterface;
use Drupal\custom_block\CustomBlockTypeInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
-class CustomBlockController implements ContainerInjectionInterface {
+class CustomBlockController extends ControllerBase implements ContainerInjectionInterface {
/**
* The entity manager.
@@ -98,10 +99,6 @@ class CustomBlockController implements ContainerInjectionInterface {
* A form array as expected by drupal_render().
*/
public function addForm(CustomBlockTypeInterface $custom_block_type, Request $request) {
- // @todo Remove this when https://drupal.org/node/1981644 is in.
- drupal_set_title(t('Add %type custom block', array(
- '%type' => $custom_block_type->label()
- )), PASS_THROUGH);
$block = $this->customBlockStorage->create(array(
'type' => $custom_block_type->id()
));
@@ -114,4 +111,17 @@ class CustomBlockController implements ContainerInjectionInterface {
return $this->entityManager->getForm($block);
}
+ /**
+ * Provides the page title for this controller.
+ *
+ * @param \Drupal\custom_block\CustomBlockTypeInterface $custom_block_type
+ * The custom block type being added.
+ *
+ * @return string
+ * The page title.
+ */
+ public function getAddFormTitle(CustomBlockTypeInterface $custom_block_type) {
+ return $this->t('Add %type custom block', array('%type' => $custom_block_type->label()));
+ }
+
}
diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php
index edae0ca..8b04b7e 100644
--- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php
+++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php
@@ -43,8 +43,7 @@ class CustomBlockFormController extends ContentEntityFormController {
$block = $this->entity;
if ($this->operation == 'edit') {
- // @todo Remove this once https://drupal.org/node/1981644 is in.
- drupal_set_title(t('Edit custom block %label', array('%label' => $block->label())), PASS_THROUGH);
+ $form['#title'] = $this->t('Edit custom block %label', array('%label' => $block->label()));
}
// Override the default CSS class name, since the user-defined custom block
// type name in 'TYPE-block-form' potentially clashes with third-party class
diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeListController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeListController.php
index efa4380..070171d 100644
--- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeListController.php
+++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeListController.php
@@ -50,10 +50,8 @@ class CustomBlockTypeListController extends ConfigEntityListController {
/**
* {@inheritdoc}
*/
- public function render() {
- // @todo Remove this once https://drupal.org/node/2032535 is in.
- drupal_set_title(t('Custom block types'));
- return parent::render();
+ protected function getTitle() {
+ return $this->t('Custom block types');
}
}