NodePreviewController.php in Zircon Profile 8.0
File
core/modules/node/src/Controller/NodePreviewController.php
View source
<?php
namespace Drupal\node\Controller;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\Controller\EntityViewController;
class NodePreviewController extends EntityViewController {
public function view(EntityInterface $node_preview, $view_mode_id = 'full', $langcode = NULL) {
$node_preview->preview_view_mode = $view_mode_id;
$build = parent::view($node_preview, $view_mode_id);
$build['#attached']['library'][] = 'node/drupal.node.preview';
unset($build['#cache']);
foreach ($node_preview
->uriRelationships() as $rel) {
$build['#attached']['html_head_link'][] = array(
array(
'rel' => $rel,
'href' => $node_preview
->url($rel),
),
TRUE,
);
if ($rel == 'canonical') {
$build['#attached']['html_head_link'][] = array(
array(
'rel' => 'shortlink',
'href' => $node_preview
->url($rel, array(
'alias' => TRUE,
)),
),
TRUE,
);
}
}
return $build;
}
public function title(EntityInterface $node_preview) {
return $this->entityManager
->getTranslationFromContext($node_preview)
->label();
}
}