LogViewController.php in Log entity 8
Contains \Drupal\log\Controller\LogViewController.
Namespace
Drupal\log\ControllerFile
src/Controller/LogViewController.phpView source
<?php
/**
* @file
* Contains \Drupal\log\Controller\LogViewController.
*/
namespace Drupal\log\Controller;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\Controller\EntityViewController;
/**
* Defines a controller to render a single log.
*/
class LogViewController extends EntityViewController {
/**
* {@inheritdoc}
*/
public function view(EntityInterface $log, $view_mode = 'full') {
$build = parent::view($log, $view_mode);
foreach ($log
->uriRelationships() as $rel) {
// Set the log path as the canonical URL to prevent duplicate content.
$build['#attached']['html_head_link'][] = array(
array(
'rel' => $rel,
'href' => $log
->toUrl($rel),
),
TRUE,
);
if ($rel == 'canonical') {
// Set the non-aliased canonical path as a default shortlink.
$build['#attached']['html_head_link'][] = array(
array(
'rel' => 'shortlink',
'href' => $log
->toUrl($rel, array(
'alias' => TRUE,
)),
),
TRUE,
);
}
}
return $build;
}
}
Classes
Name | Description |
---|---|
LogViewController | Defines a controller to render a single log. |