You are here

class SupportTicketViewController in Support Ticketing System 8

Defines a controller to render a single support ticket.

Hierarchy

Expanded class hierarchy of SupportTicketViewController

File

modules/support_ticket/src/Controller/SupportTicketViewController.php, line 17
Contains \Drupal\support_ticket\Controller\SupportTicketViewController.

Namespace

Drupal\support_ticket\Controller
View source
class SupportTicketViewController extends EntityViewController {

  /**
   * {@inheritdoc}
   */
  public function view(EntityInterface $support_ticket, $view_mode = 'full', $langcode = NULL) {
    $build = parent::view($support_ticket);
    foreach ($support_ticket
      ->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
            ->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
              ->url($rel, array(
              'alias' => TRUE,
            )),
          ),
          TRUE,
        );
      }
    }
    return $build;
  }

  /**
   * The _title_callback for the page that renders a single support ticket.
   *
   * @param \Drupal\Core\Entity\EntityInterface $support_ticket
   *   The current support ticket.
   *
   * @return string
   *   The page title.
   */
  public function title(EntityInterface $support_ticket) {
    return $this->entityManager
      ->getTranslationFromContext($support_ticket)
      ->label();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DeprecatedServicePropertyTrait::__get public function Allows to access deprecated/removed properties.
EntityViewController::$deprecatedProperties protected property
EntityViewController::$entityTypeManager protected property The entity type manager.
EntityViewController::$renderer protected property The renderer service.
EntityViewController::buildTitle public function Pre-render callback to build the page title.
EntityViewController::create public static function Instantiates a new instance of this class. Overrides ContainerInjectionInterface::create 2
EntityViewController::trustedCallbacks public static function Lists the trusted callbacks provided by the implementing class. Overrides TrustedCallbackInterface::trustedCallbacks
EntityViewController::viewRevision public function Provides a page to render a single entity revision.
EntityViewController::__construct public function Creates an EntityViewController object. 2
SupportTicketViewController::title public function The _title_callback for the page that renders a single support ticket.
SupportTicketViewController::view public function Provides a page to render a single entity. Overrides EntityViewController::view
TrustedCallbackInterface::THROW_EXCEPTION constant Untrusted callbacks throw exceptions.
TrustedCallbackInterface::TRIGGER_SILENCED_DEPRECATION constant Untrusted callbacks trigger silenced E_USER_DEPRECATION errors.
TrustedCallbackInterface::TRIGGER_WARNING constant Untrusted callbacks trigger E_USER_WARNING errors.