public function AnonymousLoginSubscriber::paths in Anonymous login 8
Same name and namespace in other branches
- 8.2 src/EventSubscriber/AnonymousLoginSubscriber.php \Drupal\anonymous_login\EventSubscriber\AnonymousLoginSubscriber::paths()
Fetch the paths.
That should be used when determining when to force anonymous users to login.
Return value
array An array of paths, keyed by "include", paths that should force a login, and "exclude", paths that should be ignored.
1 call to AnonymousLoginSubscriber::paths()
- AnonymousLoginSubscriber::redirect in src/
EventSubscriber/ AnonymousLoginSubscriber.php - Perform the anonymous user redirection, if needed.
File
- src/
EventSubscriber/ AnonymousLoginSubscriber.php, line 262
Class
- AnonymousLoginSubscriber
- Class AnonymousLoginSubscriber.
Namespace
Drupal\anonymous_login\EventSubscriberCode
public function paths() {
// Initialize the paths array.
$paths = [
'include' => [],
'exclude' => [],
];
// Fetch the stored paths set in the admin settings.
if ($setting = $this->configFactory
->get('anonymous_login.settings')
->get('paths')) {
// Split by each newline.
$setting = explode(PHP_EOL, $setting);
// Iterate each path and determine if the path should be included
// or excluded.
foreach ($setting as $path) {
if (substr($path, 0, 1) == '~') {
$path = substr($path, 1);
$path = $this
->pathSlashCut($path);
$paths['exclude'][] = $path;
}
else {
$path = $this
->pathSlashCut($path);
$paths['include'][] = $path;
}
}
}
// Always exclude certain paths.
$paths['exclude'][] = 'user/reset/*';
$paths['exclude'][] = 'cron/*';
$paths['exclude'][] = 'sites/default/files/*';
// Allow other modules to alter the paths.
$this->moduleHandler
->alter('anonymous_login_paths', $paths);
return $paths;
}