Commit 66f8fb82 authored by catch's avatar catch

Issue #2102369 by vijaycs85, JeroenT, ACF, rteijeiro, -enzo-, tim.plunkett:...

Issue #2102369 by vijaycs85, JeroenT, ACF, rteijeiro, -enzo-, tim.plunkett: Remove drupal_set_title in custom block module controllers and entitylist controllers.
parent 14bf431e
......@@ -202,6 +202,7 @@ public function render() {
$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 @@ public function setTranslationManager(TranslationInterface $translation_manager)
return $this;
}
/**
* Returns the title of the page.
*
* @return string
* A string title of the page.
*
*/
protected function getTitle() {
return;
}
}
......@@ -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'
......
......@@ -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 @@ public function add(Request $request) {
* 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 @@ public function addForm(CustomBlockTypeInterface $custom_block_type, Request $re
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()));
}
}
......@@ -43,8 +43,7 @@ public function form(array $form, array &$form_state) {
$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
......
......@@ -50,10 +50,8 @@ public function buildRow(EntityInterface $entity) {
/**
* {@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');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment