You are here

public function EntityLegalController::documentPage in Entity Legal 3.0.x

Same name and namespace in other branches
  1. 8.2 src/Controller/EntityLegalController.php \Drupal\entity_legal\Controller\EntityLegalController::documentPage()
  2. 4.0.x src/Controller/EntityLegalController.php \Drupal\entity_legal\Controller\EntityLegalController::documentPage()

Page callback for the Entity Legal Document.

Parameters

\Drupal\entity_legal\EntityLegalDocumentInterface $entity_legal_document: The Entity Legal Document entity.

\Drupal\entity_legal\EntityLegalDocumentVersionInterface|null $entity_legal_document_version: The Entity Legal Document version entity.

1 string reference to 'EntityLegalController::documentPage'
entity_legal.routing.yml in ./entity_legal.routing.yml
entity_legal.routing.yml

File

src/Controller/EntityLegalController.php, line 76

Class

EntityLegalController
Class EntityLegalController.

Namespace

Drupal\entity_legal\Controller

Code

public function documentPage(EntityLegalDocumentInterface $entity_legal_document, EntityLegalDocumentVersionInterface $entity_legal_document_version = NULL) {
  if (is_null($entity_legal_document_version)) {
    $entity_legal_document_version = $entity_legal_document
      ->getPublishedVersion();
    if (!$entity_legal_document_version) {
      throw new NotFoundHttpException();
    }
  }

  // If specified version is unpublished, display a message.
  if ($entity_legal_document_version
    ->id() != $entity_legal_document
    ->getPublishedVersion()
    ->id()) {
    \Drupal::messenger()
      ->addMessage('You are viewing an unpublished version of this legal document.', 'warning');
  }
  return \Drupal::entityTypeManager()
    ->getViewBuilder(ENTITY_LEGAL_DOCUMENT_VERSION_ENTITY_NAME)
    ->view($entity_legal_document_version);
}