diff --git a/core/modules/node/lib/Drupal/node/Controller/NodeController.php b/core/modules/node/lib/Drupal/node/Controller/NodeController.php index 8e56f58..49073e6 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 @@ 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 @@ protected function buildPage(NodeInterface $node) { 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 @@ public function getConfirmText() { 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 = '

' . 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())) . '

'; + $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\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 @@ public function form(array $form, array &$form_state) { $node = $this->entity; if ($this->operation == 'edit') { - drupal_set_title(t('Edit @type @title', array('@type' => node_get_type_label($node), '@title' => $node->label())), PASS_THROUGH); + $form['#title'] = $this->t('Edit @type @title', array('@type' => node_get_type_label($node), '@title' => $node->label())); } $user_config = \Drupal::config('user.settings'); @@ -74,6 +75,7 @@ public function form(array $form, array &$form_state) { 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 @@ 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 @@ public function form(array $form, array &$form_state) { $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 4fe1645..e450929 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -968,8 +968,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}'