summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2013-10-31 11:56:00 (GMT)
committerNathaniel Catchpole2013-10-31 11:56:00 (GMT)
commit4e6af2126a85a70afbb921c238e929555d9063fd (patch)
tree8abb2f76b4ae2b8963d88648d0f852ec9edfb026
parentb3ba231beee6bb40d755c9a255b3020f62b41025 (diff)
Issue #2102465 by vijaycs85, ACF, InternetDevels, sidharthap: Remove drupal_set_title() in node module controllers.
-rw-r--r--core/modules/node/lib/Drupal/node/Controller/NodeController.php14
-rw-r--r--core/modules/node/lib/Drupal/node/Form/NodeTypeDeleteConfirm.php2
-rw-r--r--core/modules/node/lib/Drupal/node/NodeFormController.php4
-rw-r--r--core/modules/node/lib/Drupal/node/NodeTypeFormController.php5
-rw-r--r--core/modules/node/node.module2
-rw-r--r--core/modules/node/node.pages.inc1
-rw-r--r--core/modules/node/node.routing.yml1
7 files changed, 22 insertions, 7 deletions
diff --git a/core/modules/node/lib/Drupal/node/Controller/NodeController.php b/core/modules/node/lib/Drupal/node/Controller/NodeController.php
index 8e56f58..90e5899 100644
--- a/core/modules/node/lib/Drupal/node/Controller/NodeController.php
+++ b/core/modules/node/lib/Drupal/node/Controller/NodeController.php
@@ -10,6 +10,7 @@ namespace Drupal\node\Controller;
use Drupal\Component\Utility\String;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Entity\EntityInterface;
+use Drupal\node\NodeTypeInterface;
use Drupal\node\NodeInterface;
/**
@@ -142,4 +143,17 @@ class NodeController extends ControllerBase {
return array('nodes' => $this->entityManager()->getViewBuilder('node')->view($node));
}
+ /**
+ * The _title_callback for the node.add route.
+ *
+ * @param \Drupal\node\NodeTypeInterface $node_type
+ * The current node.
+ *
+ * @return string
+ * The page title.
+ */
+ public function addPageTitle(NodeTypeInterface $node_type) {
+ return $this->t('Create @name', array('@name' => $node_type->type));
+ }
+
}
diff --git a/core/modules/node/lib/Drupal/node/Form/NodeTypeDeleteConfirm.php b/core/modules/node/lib/Drupal/node/Form/NodeTypeDeleteConfirm.php
index 04a52c0..06c5766 100644
--- a/core/modules/node/lib/Drupal/node/Form/NodeTypeDeleteConfirm.php
+++ b/core/modules/node/lib/Drupal/node/Form/NodeTypeDeleteConfirm.php
@@ -71,8 +71,8 @@ class NodeTypeDeleteConfirm extends EntityConfirmFormBase {
public function buildForm(array $form, array &$form_state) {
$num_nodes = $this->database->query("SELECT COUNT(*) FROM {node} WHERE type = :type", array(':type' => $this->entity->id()))->fetchField();
if ($num_nodes) {
- drupal_set_title($this->getQuestion(), PASS_THROUGH);
$caption = '<p>' . format_plural($num_nodes, '%type is used by 1 piece of content on your site. You can not remove this content type until you have removed all of the %type content.', '%type is used by @count pieces of content on your site. You may not remove %type until you have removed all of the %type content.', array('%type' => $this->entity->label())) . '</p>';
+ $form['#title'] = $this->getQuestion();
$form['description'] = array('#markup' => $caption);
return $form;
}
diff --git a/core/modules/node/lib/Drupal/node/NodeFormController.php b/core/modules/node/lib/Drupal/node/NodeFormController.php
index a787175..e14a662 100644
--- a/core/modules/node/lib/Drupal/node/NodeFormController.php
+++ b/core/modules/node/lib/Drupal/node/NodeFormController.php
@@ -11,6 +11,7 @@ use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Core\Entity\ContentEntityFormController;
use Drupal\Core\Language\Language;
+use Drupal\Component\Utility\String;
/**
* Form controller for the node edit forms.
@@ -66,7 +67,7 @@ class NodeFormController extends ContentEntityFormController {
$node = $this->entity;
if ($this->operation == 'edit') {
- drupal_set_title(t('<em>Edit @type</em> @title', array('@type' => node_get_type_label($node), '@title' => $node->label())), PASS_THROUGH);
+ $form['#title'] = $this->t('<em>Edit @type</em> @title', array('@type' => node_get_type_label($node), '@title' => $node->label()));
}
$user_config = \Drupal::config('user.settings');
@@ -74,6 +75,7 @@ class NodeFormController extends ContentEntityFormController {
if (isset($form_state['node_preview'])) {
$form['#prefix'] = $form_state['node_preview'];
$node->in_preview = TRUE;
+ $form['#title'] = $this->t('Preview');
}
else {
unset($node->in_preview);
diff --git a/core/modules/node/lib/Drupal/node/NodeTypeFormController.php b/core/modules/node/lib/Drupal/node/NodeTypeFormController.php
index d9d5666..a385b20 100644
--- a/core/modules/node/lib/Drupal/node/NodeTypeFormController.php
+++ b/core/modules/node/lib/Drupal/node/NodeTypeFormController.php
@@ -9,6 +9,7 @@ namespace Drupal\node;
use Drupal\Core\Entity\EntityFormController;
use Symfony\Component\DependencyInjection\ContainerInterface;
+use Drupal\Component\Utility\String;
/**
* Form controller for node type forms.
@@ -23,10 +24,10 @@ class NodeTypeFormController extends EntityFormController {
$type = $this->entity;
if ($this->operation == 'add') {
- drupal_set_title(t('Add content type'));
+ $form['#title'] = String::checkPlain($this->t('Add content type'));
}
elseif ($this->operation == 'edit') {
- drupal_set_title(t('Edit %label content type', array('%label' => $type->label())), PASS_THROUGH);
+ $form['#title'] = $this->t('Edit %label content type', array('%label' => $type->label()));
}
$node_settings = $type->getModuleSettings('node');
diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index 5c10fbb..9a4f809 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -971,8 +971,6 @@ function node_menu() {
'route_name' => 'node.add_page',
);
$items['node/add/%node_type'] = array(
- 'title callback' => 'entity_page_label',
- 'title arguments' => array(2),
'description callback' => 'node_type_get_description',
'description arguments' => array(2),
'route_name' => 'node.add',
diff --git a/core/modules/node/node.pages.inc b/core/modules/node/node.pages.inc
index 9783ed8..53dc99a 100644
--- a/core/modules/node/node.pages.inc
+++ b/core/modules/node/node.pages.inc
@@ -96,7 +96,6 @@ function node_add($node_type) {
'type' => $type,
'langcode' => $langcode ? $langcode : language_default()->id,
));
- drupal_set_title(t('Create @name', array('@name' => $node_type->name)), PASS_THROUGH);
return \Drupal::entityManager()->getForm($node);
}
diff --git a/core/modules/node/node.routing.yml b/core/modules/node/node.routing.yml
index 8c92237..b87bb76 100644
--- a/core/modules/node/node.routing.yml
+++ b/core/modules/node/node.routing.yml
@@ -35,6 +35,7 @@ node.add:
path: '/node/add/{node_type}'
defaults:
_content: '\Drupal\node\Controller\NodeController::add'
+ _title_callback: '\Drupal\node\Controller\NodeController::addPageTitle'
requirements:
_node_add_access: 'node:{node_type}'