public function ProtectedPagesSubscriber::checkProtectedPage in Protected Pages 8
Redirects user to protected page login screen.
Parameters
\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event: The event to process.
File
- src/
EventSubscriber/ ProtectedPagesSubscriber.php, line 106
Class
- ProtectedPagesSubscriber
- Redirects user to protected page login screen.
Namespace
Drupal\protected_pages\EventSubscriberCode
public function checkProtectedPage(FilterResponseEvent $event) {
if ($this->currentUser
->hasPermission('bypass pages password protection')) {
return;
}
$current_path = $this->aliasManager
->getAliasByPath($this->currentPath
->getPath());
$normal_path = mb_strtolower($this->aliasManager
->getPathByAlias($current_path));
$pid = $this
->protectedPagesIsPageLocked($current_path, $normal_path);
$this
->sendAccessDenied($pid);
if (empty($pid)) {
$page_node = \Drupal::request()->attributes
->get('node');
if (is_object($page_node)) {
$nid = $page_node
->id();
if (isset($nid) && is_numeric($nid)) {
$path_to_node = '/node/' . $nid;
$current_path = mb_strtolower($this->aliasManager
->getAliasByPath($path_to_node));
$normal_path = mb_strtolower($this->aliasManager
->getPathByAlias($current_path));
$pid = $this
->protectedPagesIsPageLocked($current_path, $normal_path);
$this
->sendAccessDenied($pid);
}
}
}
}