public function ModalPageService::checkModalToShow in Modal 5.0.x
Function to check Modal will show.
File
- src/
Service/ ModalPageService.php, line 106
Class
- ModalPageService
- Modal Page Service Class.
Namespace
Drupal\modal_page\ServiceCode
public function checkModalToShow() {
$modalToShow = $this
->getModalToShow();
if (empty($modalToShow)) {
return FALSE;
}
$button = $this
->t('OK');
if (!empty($modalToShow
->getOkLabelButton())) {
$button = $this
->clearText($modalToShow
->getOkLabelButton());
}
$body = '';
// Check body by string.
if (gettype($modalToShow
->getBody() == 'string' && !empty($modalToShow
->getBody()))) {
$body = $modalToShow
->getBody();
}
// Check by array.
if (!empty($modalToShow
->getBody()['value'])) {
$body = $modalToShow
->getBody()['value'];
}
$result = [
'id' => $modalToShow
->id(),
'title' => $this
->clearText($modalToShow
->label()),
'text' => $this
->getAutheticatedUserName($this
->clearText($body)),
'delay_display' => $modalToShow
->getDelayDisplay(),
'modal_size' => $modalToShow
->getModalSize(),
'button' => $button,
'do_not_show_again' => empty($modalToShow
->getDontShowAgainLabel()) ? $this
->t("Don't show again") : $modalToShow
->getDontShowAgainLabel(),
'close_modal_esc_key' => $modalToShow
->getCloseModalEscKey() == 1 ? 'true' : "false",
'close_modal_clicking_outside' => $modalToShow
->getCloseModalClickingOutside() == 1 ? "true" : "static",
'open_modal_on_element_click' => $modalToShow
->getOpenModalOnElementClick(),
'auto_open' => $modalToShow
->getAutoOpen(),
];
if ($modalToShow
->getEnableDontShowAgainOption() == FALSE) {
unset($result['do_not_show_again']);
}
return $result;
}