/**
   * {@inheritdoc}
   */
  protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
    switch ($operation) {
      case 'view':
        $url_string = $entity->context->value;
        $decoded_url = rawurldecode($url_string);
        return $this->accessHelper->canGeneratePdfFromUrlString($decoded_url, $account);

      case 'update':
        return AccessResult::forbidden();

      case 'delete':
        return AccessResult::allowedIfHasPermission($account, 'administer pdfs');
    }

    return AccessResult::allowed();
  }
  public function checkLink() {
    $context = $this->linkManipulator->parseRequest($this->requestStack->getCurrentRequest());
    $account = $this->currentUser;

    return $this->accessHelper->canGeneratePdfFromContext($context, $account);
  }