public function Lazy::isPathAllowed in Lazy-load 8.3
Is lazy-loading allowed for current path?
Return value
bool Returns TRUE if lazy-loading is allowed for current path.
Overrides LazyInterface::isPathAllowed
1 call to Lazy::isPathAllowed()
- Lazy::isEnabled in src/
Lazy.php - Is Lazy-load enabled?
File
- src/
Lazy.php, line 130
Class
- Lazy
- Lazy-load service.
Namespace
Drupal\lazyCode
public function isPathAllowed() : bool {
// Disable lazy-loading for all AMP pages.
if ($this->requestStack->query
->has('amp')) {
return FALSE;
}
$settings = $this
->getSettings();
// Disable lazy-loading on all administrative pages.
$disable_admin = !isset($settings['disable_admin']) || (bool) $settings['disable_admin'];
if ($disable_admin && $this->adminContext
->isAdminRoute()) {
return FALSE;
}
/** @var \Drupal\system\Plugin\Condition\RequestPath $condition */
$condition = $this->conditionManager
->createInstance('request_path');
if (is_null($condition)) {
return FALSE;
}
$visibility = $settings['visibility'] ?? [
'id' => 'request_path',
'pages' => $settings['disabled_paths'] ?? '/rss.xml',
'negate' => 0,
];
$condition
->setConfiguration($visibility);
if ($condition
->isNegated()) {
return $condition
->evaluate();
}
return !$condition
->evaluate();
}