class WebformSubmissionViewController in Webform 8.5
Same name and namespace in other branches
- 6.x src/Controller/WebformSubmissionViewController.php \Drupal\webform\Controller\WebformSubmissionViewController
Defines a controller to render a single webform submission.
Hierarchy
- class \Drupal\Core\Entity\Controller\EntityViewController implements ContainerInjectionInterface, TrustedCallbackInterface uses DeprecatedServicePropertyTrait- class \Drupal\webform\Controller\WebformSubmissionViewController uses StringTranslationTrait
 
Expanded class hierarchy of WebformSubmissionViewController
File
- src/Controller/ WebformSubmissionViewController.php, line 17 
Namespace
Drupal\webform\ControllerView source
class WebformSubmissionViewController extends EntityViewController {
  use StringTranslationTrait;
  /**
   * The current user.
   *
   * @var \Drupal\Core\Session\AccountInterface
   */
  protected $currentUser;
  /**
   * The webform request handler.
   *
   * @var \Drupal\webform\WebformRequestInterface
   */
  protected $requestHandler;
  /**
   * Creates an WebformSubmissionViewController object.
   *
   * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
   *   The entity manager.
   * @param \Drupal\Core\Render\RendererInterface $renderer
   *   The renderer service.
   * @param \Drupal\Core\Session\AccountInterface $current_user
   *   The current user.
   * @param \Drupal\webform\WebformRequestInterface $webform_request
   *   The webform request handler.
   */
  public function __construct(EntityManagerInterface $entity_manager, RendererInterface $renderer, AccountInterface $current_user, WebformRequestInterface $webform_request) {
    parent::__construct($entity_manager, $renderer);
    $this->currentUser = $current_user;
    $this->requestHandler = $webform_request;
  }
  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static($container
      ->get('entity.manager'), $container
      ->get('renderer'), $container
      ->get('current_user'), $container
      ->get('webform.request'));
  }
  /**
   * {@inheritdoc}
   */
  public function view(EntityInterface $webform_submission, $view_mode = 'default', $langcode = NULL) {
    $webform = $this->requestHandler
      ->getCurrentWebform();
    $source_entity = $this->requestHandler
      ->getCurrentSourceEntity('webform_submission');
    // Set webform submission template.
    $build = [
      '#theme' => 'webform_submission',
      '#view_mode' => $view_mode,
      '#webform_submission' => $webform_submission,
    ];
    // Navigation.
    $build['navigation'] = [
      '#type' => 'webform_submission_navigation',
      '#webform_submission' => $webform_submission,
    ];
    // Information.
    $build['information'] = [
      '#type' => 'webform_submission_information',
      '#webform_submission' => $webform_submission,
      '#source_entity' => $source_entity,
    ];
    // Submission.
    $build['submission'] = parent::view($webform_submission, $view_mode, $langcode);
    // Library.
    $build['#attached']['library'][] = 'webform/webform.admin';
    // Add entities cacheable dependency.
    $this->renderer
      ->addCacheableDependency($build, $this->currentUser);
    $this->renderer
      ->addCacheableDependency($build, $webform);
    $this->renderer
      ->addCacheableDependency($build, $webform_submission);
    if ($source_entity) {
      $this->renderer
        ->addCacheableDependency($build, $source_entity);
    }
    return $build;
  }
  /**
   * The _title_callback for the page that renders a single webform submission.
   *
   * @param \Drupal\Core\Entity\EntityInterface $webform_submission
   *   The current webform submission.
   * @param bool $duplicate
   *   Flag indicating if submission is being duplicated.
   *
   * @return string
   *   The page title.
   */
  public function title(EntityInterface $webform_submission, $duplicate = FALSE) {
    $title = $this->entityManager
      ->getTranslationFromContext($webform_submission)
      ->label();
    return $duplicate ? $this
      ->t('Duplicate @title', [
      '@title' => $title,
    ]) : $title;
  }
}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 | Lists the trusted callbacks provided by the implementing class. Overrides TrustedCallbackInterface:: | |
| EntityViewController:: | public | function | Provides a page to render a single entity revision. | |
| StringTranslationTrait:: | protected | property | The string translation service. | 1 | 
| StringTranslationTrait:: | protected | function | Formats a string containing a count of items. | |
| StringTranslationTrait:: | protected | function | Returns the number of plurals supported by a given language. | |
| StringTranslationTrait:: | protected | function | Gets the string translation service. | |
| StringTranslationTrait:: | public | function | Sets the string translation service to use. | 2 | 
| StringTranslationTrait:: | protected | function | Translates a string to the current language or to a given language. | |
| 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. | ||
| WebformSubmissionViewController:: | protected | property | The current user. | |
| WebformSubmissionViewController:: | protected | property | The webform request handler. | |
| WebformSubmissionViewController:: | public static | function | Instantiates a new instance of this class. Overrides EntityViewController:: | |
| WebformSubmissionViewController:: | public | function | The _title_callback for the page that renders a single webform submission. | |
| WebformSubmissionViewController:: | public | function | Provides a page to render a single entity. Overrides EntityViewController:: | |
| WebformSubmissionViewController:: | public | function | Creates an WebformSubmissionViewController object. Overrides EntityViewController:: | 
