You are here

public function ProtectedPagesSubscriber::sendAccessDenied in Protected Pages 8

Send Access Denied for pid.

Parameters

int $pid: The Protected Page ID.

1 call to ProtectedPagesSubscriber::sendAccessDenied()
ProtectedPagesSubscriber::checkProtectedPage in src/EventSubscriber/ProtectedPagesSubscriber.php
Redirects user to protected page login screen.

File

src/EventSubscriber/ProtectedPagesSubscriber.php, line 144

Class

ProtectedPagesSubscriber
Redirects user to protected page login screen.

Namespace

Drupal\protected_pages\EventSubscriber

Code

public function sendAccessDenied($pid) {
  if (empty($pid)) {
    return;
  }
  $query = \Drupal::destination()
    ->getAsArray();
  $query['protected_page'] = $pid;
  $this->pageCacheKillSwitch
    ->trigger();
  $response = new RedirectResponse(Url::fromUri('internal:/protected-page', [
    'query' => $query,
  ])
    ->toString());
  $response
    ->send();
}