You are here

public function CertificateController::view in Opigno certificate 3.x

Same name and namespace in other branches
  1. 8 src/Controller/CertificateController.php \Drupal\opigno_certificate\Controller\CertificateController::view()

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 call to CertificateController::view()
CertificateController::viewEntity in src/Controller/CertificateController.php
Callback to view the opigno_certificate entity attached to any entity.

File

src/Controller/CertificateController.php, line 80

Class

CertificateController
Defines a controller to render a single opigno_certificate.

Namespace

Drupal\opigno_certificate\Controller

Code

public function view(EntityInterface $opigno_certificate, $view_mode = 'full') {

  /** @var \Drupal\opigno_certificate\OpignoCertificateInterface $opigno_certificate */

  // @todo: check opigno_certificate access before rendering the opigno_certificate.
  // @todo: implement entity access to check that user has completed learning
  // path. This will need to be a custom access operation other than 'view'.

  /*if ($entity = $opigno_certificate->referencing_entity->entity) {
    $title = $entity->label();
    }*/
  if (in_array($view_mode, [
    'full',
    'default',
  ]) && $opigno_certificate
    ->getViewModeSelectorField()) {
    $view_mode = 'view_mode_selector';
  }
  $build = parent::view($opigno_certificate, $view_mode);
  return $build;
}