class SupportTicketPreviewController in Support Ticketing System 8
Defines a controller to render a single support ticket in preview.
Hierarchy
- class \Drupal\Core\Entity\Controller\EntityViewController implements ContainerInjectionInterface, TrustedCallbackInterface uses DeprecatedServicePropertyTrait
- class \Drupal\support_ticket\Controller\SupportTicketPreviewController
Expanded class hierarchy of SupportTicketPreviewController
File
- modules/
support_ticket/ src/ Controller/ SupportTicketPreviewController.php, line 17 - Contains \Drupal\support_ticket\Controller\SupportTicketPreviewController.
Namespace
Drupal\support_ticket\ControllerView source
class SupportTicketPreviewController extends EntityViewController {
/**
* {@inheritdoc}
*/
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;
}
/**
* The _title_callback for the page that renders a single support ticket in preview.
*
* @param \Drupal\Core\Entity\EntityInterface $support_ticket_preview
* The current support ticket.
*
* @return string
* The page title.
*/
public function title(EntityInterface $support_ticket_preview) {
return SafeMarkup::checkPlain($this->entityManager
->getTranslationFromContext($support_ticket_preview)
->label());
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeprecatedServicePropertyTrait:: |
public | function | Allows to access deprecated/removed properties. | |
EntityViewController:: |
protected | property | ||
EntityViewController:: |
protected | property | The entity type manager. | |
EntityViewController:: |
protected | property | The renderer service. | |
EntityViewController:: |
public | function | Pre-render callback to build the page title. | |
EntityViewController:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
2 |
EntityViewController:: |
public static | function |
Lists the trusted callbacks provided by the implementing class. Overrides TrustedCallbackInterface:: |
|
EntityViewController:: |
public | function | Provides a page to render a single entity revision. | |
EntityViewController:: |
public | function | Creates an EntityViewController object. | 2 |
SupportTicketPreviewController:: |
public | function | The _title_callback for the page that renders a single support ticket in preview. | |
SupportTicketPreviewController:: |
public | function |
Provides a page to render a single entity. Overrides EntityViewController:: |
|
TrustedCallbackInterface:: |
constant | Untrusted callbacks throw exceptions. | ||
TrustedCallbackInterface:: |
constant | Untrusted callbacks trigger silenced E_USER_DEPRECATION errors. | ||
TrustedCallbackInterface:: |
constant | Untrusted callbacks trigger E_USER_WARNING errors. |