diff --git a/core/modules/node/lib/Drupal/node/Controller/NodeController.php b/core/modules/node/lib/Drupal/node/Controller/NodeController.php index c889adc..fdfaf94 100644 --- a/core/modules/node/lib/Drupal/node/Controller/NodeController.php +++ b/core/modules/node/lib/Drupal/node/Controller/NodeController.php @@ -142,4 +142,17 @@ protected function buildPage(NodeInterface $node) { return array('nodes' => $this->entityManager()->getRenderController('node')->view($node)); } + /** + * The _title_callback for the node.add route. + * + * @param EntityInterface $node_type + * The current node. + * + * @return string + * The page title. + */ + public function addPageTitle(EntityInterface $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..3dfc7a5 100644 --- a/core/modules/node/lib/Drupal/node/Form/NodeTypeDeleteConfirm.php +++ b/core/modules/node/lib/Drupal/node/Form/NodeTypeDeleteConfirm.php @@ -10,6 +10,7 @@ use Drupal\Core\Entity\EntityConfirmFormBase; use Drupal\Core\Database\Connection; use Symfony\Component\DependencyInjection\ContainerInterface; +use Drupal\Component\Utility\String; /** * Provides a form for content type deletion. @@ -71,8 +72,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..092e71a 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); @@ -400,7 +402,6 @@ public function preview(array $form, array &$form_state) { // @todo Remove this: we should not have explicit includes in autoloaded // classes. module_load_include('inc', 'node', 'node.pages'); - drupal_set_title(t('Preview'), PASS_THROUGH); $form_state['node_preview'] = node_preview($this->entity); $form_state['rebuild'] = TRUE; } 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 0ad789d..d5fb0e5 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -958,8 +958,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..e44d253 100644 --- a/core/modules/node/node.pages.inc +++ b/core/modules/node/node.pages.inc @@ -96,7 +96,7 @@ 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}'