Issue #2102465 by vijaycs85, ACF, InternetDevels, sidharthap: Remove drupal_set_title() in node module controllers.
parent
b3ba231bee
commit
4e6af2126a
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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}'
|
||||
|
||||
|
|
Loading…
Reference in New Issue