function _mautic_visibility_pages in Mautic Integration 8
Tracking visibility check for pages.
Based on visibility setting this function returns TRUE if JS code should be added to the current page and otherwise FALSE.
1 call to _mautic_visibility_pages()
- mautic_page_attachments in ./
mautic.module - Implements hook_page_attachments().
File
- ./
mautic.module, line 83 - Drupal Module: Mautic.
Code
function _mautic_visibility_pages() {
static $page_match;
if (!isset($page_match)) {
$config = \Drupal::config('mautic.settings');
$visibility_request_path_mode = $config
->get('visibility.request_path_mode');
$visibility_request_path_pages = $config
->get('visibility.request_path_pages');
if (!empty($visibility_request_path_pages)) {
$pages = mb_strtolower($visibility_request_path_pages);
if ($visibility_request_path_mode < 2) {
$path = \Drupal::service('path.current')
->getPath();
$path_alias = mb_strtolower(\Drupal::service('path_alias.manager')
->getAliasByPath($path));
$page_match = \Drupal::service('path.matcher')
->matchPath($path_alias, $pages) || $path != $path_alias && \Drupal::service('path.matcher')
->matchPath($path, $pages);
$page_match = !($visibility_request_path_mode xor $page_match);
}
else {
$page_match = FALSE;
}
}
else {
$page_match = TRUE;
}
}
return $page_match;
}