public function SupportTicketPreviewController::view in Support Ticketing System 8
Provides a page to render a single entity.
Parameters
\Drupal\Core\Entity\EntityInterface $_entity: The Entity to be rendered. Note this variable is named $_entity rather than $entity to prevent collisions with other named placeholders in the route.
string $view_mode: (optional) The view mode that should be used to display the entity. Defaults to 'full'.
Return value
array A render array as expected by \Drupal\Core\Render\RendererInterface::render().
Overrides EntityViewController::view
1 string reference to 'SupportTicketPreviewController::view'
- support_ticket.routing.yml in modules/
support_ticket/ support_ticket.routing.yml - modules/support_ticket/support_ticket.routing.yml
File
- modules/
support_ticket/ src/ Controller/ SupportTicketPreviewController.php, line 22 - Contains \Drupal\support_ticket\Controller\SupportTicketPreviewController.
Class
- SupportTicketPreviewController
- Defines a controller to render a single support ticket in preview.
Namespace
Drupal\support_ticket\ControllerCode
public function view(EntityInterface $support_ticket_preview, $view_mode_id = 'full', $langcode = NULL) {
$support_ticket_preview->preview_view_mode = $view_mode_id;
$build = parent::view($support_ticket_preview, $view_mode_id);
$build['#attached']['library'][] = 'support_ticket/drupal.support_ticket.preview';
// Don't render cache previews.
unset($build['#cache']);
foreach ($support_ticket_preview
->uriRelationships() as $rel) {
// Set the support ticket path as the canonical URL to prevent duplicate tickets.
$build['#attached']['html_head_link'][] = array(
array(
'rel' => $rel,
'href' => $support_ticket_preview
->url($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' => $support_ticket_preview
->url($rel, array(
'alias' => TRUE,
)),
),
TRUE,
);
}
}
return $build;
}