public function ModalPage::getModalToShowByPage in Modal 8.2
Same name and namespace in other branches
- 8.3 src/ModalPage.php \Drupal\modal_page\ModalPage::getModalToShowByPage()
Get the modal by page.
Parameters
object $modal: The object modal.
string $currentPath: The current path.
Return value
object Retunr the modal.
1 call to ModalPage::getModalToShowByPage()
- ModalPage::getModalToShow in src/
ModalPage.php - Get modal to show.
File
- src/
ModalPage.php, line 256
Class
- ModalPage
- Modal Page Class.
Namespace
Drupal\modal_pageCode
public function getModalToShowByPage($modal, $currentPath) {
$pages = $modal->pages->value;
$pages = explode(PHP_EOL, $pages);
$currentPath = mb_strtolower($currentPath);
foreach ($pages as $page) {
$path = mb_strtolower($page);
if ($path != '<front>') {
$path = Xss::filter($path);
}
$path = trim($path);
$currentPath = $this->aliasManager
->getPathByAlias($currentPath);
$path = str_replace('/', '\\/', str_replace('*', '\\.*', $path));
if (preg_match('/^' . $path . '/', $currentPath)) {
return $modal;
}
}
}