public function ModalPageService::getModalsToShow in Modal 4.1.x
Same name and namespace in other branches
- 4.0.x src/Service/ModalPageService.php \Drupal\modal_page\Service\ModalPageService::getModalsToShow()
Method to Get Modals to show.
File
- src/
Service/ ModalPageService.php, line 124
Class
- ModalPageService
- Modal Page Service Class.
Namespace
Drupal\modal_page\ServiceCode
public function getModalsToShow() {
// Get Modals to Show.
$modals = $this
->loadModalsToShow();
if (empty($modals)) {
return FALSE;
}
foreach ($modals as $key => $modal) {
$body = '';
// Verify body by string.
if (is_string($modal
->getBody()) && !empty($modal
->getBody())) {
$body = $this
->clearText($modal
->getBody());
}
// Verify by array.
if (!empty($modal
->getBody()['value'])) {
$body = [
'#type' => 'processed_text',
'#text' => $modal
->getBody()['value'],
'#format' => $modal
->getBody()['format'],
];
}
$modal
->setBody($body);
// Default Top Right Button.
if (empty($modal
->getTopRightButtonLabel()) || $modal
->getTopRightButtonLabel() == 'x') {
$modal
->setTopRightButtonLabel('×');
}
if (empty($modal
->getEnableDontShowAgainOption())) {
$modal
->setDontShowAgainLabel(FALSE);
}
// Default classes for Modal class. If there are user class, include it.
$modalClass = 'modal fade js-modal-page-show';
if (!empty($modal
->getModalClass())) {
$modalClass .= ' ' . $modal
->getModalClass();
}
$modal
->setModalClass($modalClass);
// Header class.
$headerClass = $modal
->getHeaderClass();
if (empty($modal
->getInsertHorizontalLineHeader())) {
$headerClass .= ' modal-no-border';
$modal
->setHeaderClass($headerClass);
}
// Other class.
$footerClass = $modal
->getFooterClass();
if (empty($modal
->getInsertHorizontalLineFooter())) {
$footerClass .= ' modal-no-border';
$modal
->setFooterClass($footerClass);
}
// Prepare Get close Modal Esc Key.
$closeModalEscKey = 'true';
if (empty($modal
->getCloseModalEscKey())) {
$closeModalEscKey = 'false';
}
$modal
->setCloseModalEscKey($closeModalEscKey);
// Prepare Get close Modal clicking Outside.
$closeModalClickingOutside = 'true';
if (empty($modal
->getCloseModalClickingOutside())) {
$closeModalClickingOutside = 'static';
}
$modal
->setCloseModalClickingOutside($closeModalClickingOutside);
$modals[$key] = $modal;
}
return $modals;
}