Issue #2832074 by sahil.goyal, TanujJain-TJ, SchnWalter, Sweetchuck, leolandotan, Chi, DanielVeza, ameymudras: Fix hook_page_top implementation for node.module
parent
e2564e1cce
commit
8df5eabfba
|
@ -32,6 +32,7 @@ use Drupal\node\Entity\NodeType;
|
||||||
use Drupal\node\NodeInterface;
|
use Drupal\node\NodeInterface;
|
||||||
use Drupal\node\NodeTypeInterface;
|
use Drupal\node\NodeTypeInterface;
|
||||||
use Drupal\user\UserInterface;
|
use Drupal\user\UserInterface;
|
||||||
|
use Drupal\node\Form\NodePreviewForm;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements hook_help().
|
* Implements hook_help().
|
||||||
|
@ -752,19 +753,21 @@ function node_get_recent($number = 10) {
|
||||||
/**
|
/**
|
||||||
* Implements hook_page_top().
|
* Implements hook_page_top().
|
||||||
*/
|
*/
|
||||||
function node_page_top(array &$page) {
|
function node_page_top(array &$page_top) {
|
||||||
// Add 'Back to content editing' link on preview page.
|
// Add 'Back to content editing' link on preview page.
|
||||||
$route_match = \Drupal::routeMatch();
|
$route_match = \Drupal::routeMatch();
|
||||||
if ($route_match->getRouteName() == 'entity.node.preview') {
|
if ($route_match->getRouteName() == 'entity.node.preview') {
|
||||||
$page['page_top']['node_preview'] = [
|
$page_top['node_preview'] = [
|
||||||
'#type' => 'container',
|
'#type' => 'container',
|
||||||
'#attributes' => [
|
'#attributes' => [
|
||||||
'class' => ['node-preview-container', 'container-inline'],
|
'class' => ['node-preview-container', 'container-inline'],
|
||||||
],
|
],
|
||||||
|
'view_mode' => \Drupal::formBuilder()->getForm(
|
||||||
|
NodePreviewForm::class,
|
||||||
|
$route_match->getParameter('node_preview')
|
||||||
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
$form = \Drupal::formBuilder()->getForm('\Drupal\node\Form\NodePreviewForm', $route_match->getParameter('node_preview'));
|
|
||||||
$page['page_top']['node_preview']['view_mode'] = $form;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue