Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / node / src / Controller / NodePreviewController.php
1 <?php
2
3 namespace Drupal\node\Controller;
4
5 use Drupal\Core\Entity\EntityInterface;
6 use Drupal\Core\Entity\Controller\EntityViewController;
7
8 /**
9  * Defines a controller to render a single node in preview.
10  */
11 class NodePreviewController extends EntityViewController {
12
13   /**
14    * {@inheritdoc}
15    */
16   public function view(EntityInterface $node_preview, $view_mode_id = 'full', $langcode = NULL) {
17     $node_preview->preview_view_mode = $view_mode_id;
18     $build = parent::view($node_preview, $view_mode_id);
19
20     $build['#attached']['library'][] = 'node/drupal.node.preview';
21
22     // Don't render cache previews.
23     unset($build['#cache']);
24
25     return $build;
26   }
27
28   /**
29    * The _title_callback for the page that renders a single node in preview.
30    *
31    * @param \Drupal\Core\Entity\EntityInterface $node_preview
32    *   The current node.
33    *
34    * @return string
35    *   The page title.
36    */
37   public function title(EntityInterface $node_preview) {
38     return $this->entityManager->getTranslationFromContext($node_preview)->label();
39   }
40
41 }