function _bootstrap_library_check_url in Bootstrap Library 8
Check if bootstrap_library should be active for the current URL.
Return value
bool TRUE if bootstrap_library should be active for the current page.
1 call to _bootstrap_library_check_url()
- bootstrap_library_page_attachments in ./
bootstrap_library.module - Implements hook_page_attachments().
File
- ./
bootstrap_library.module, line 102 - Primarily Drupal hooks.
Code
function _bootstrap_library_check_url() {
// Make it possible deactivate bootstrap with
// parameter ?bootstrap_library=no in the url.
if (isset($_GET['bootstrap']) && $_GET['bootstrap'] == 'no') {
return FALSE;
}
// Assume there are no matches until one is found.
$page_match = FALSE;
// Convert path to lowercase. This allows comparison of the same path
// with different case. Ex: /Page, /page, /PAGE.
$config = \Drupal::config('bootstrap_library.settings');
$pages = Unicode::strtolower(_bootstrap_library_array_to_string($config
->get('url.pages')));
// Compare the lowercase path alias (if any) and internal path.
$path = Url::fromRoute('<current>')
->toString();
$path_alias = Unicode::strtolower(\Drupal::service('path.alias_storage')
->lookupPathAlias($path, 'en'));
$page_match = \Drupal::service('path.matcher')
->matchPath($path_alias, $pages);
if ($path_alias != $path) {
$page_match = $page_match || \Drupal::service('path.matcher')
->matchPath($path, $pages);
}
$page_match = $config
->get('url.visibility') == 0 ? !$page_match : $page_match;
return $page_match;
}