public function ModalController::modal in Business Rules 8
Same name and namespace in other branches
- 2.x src/Controller/ModalController.php \Drupal\business_rules\Controller\ModalController::modal()
Provide the modal page.
Parameters
string $collection: The keyvalue collection witch contains the page content.
string $key: The keyvalue key witch contains the page content.
string $title: The title for the modal content.
string $method: The method tho show the content: ajax|nojs.
Return value
array|\Drupal\Core\Ajax\AjaxResponse The help content.
1 string reference to 'ModalController::modal'
File
- src/
Controller/ ModalController.php, line 55
Class
- ModalController
- Class HelpController.
Namespace
Drupal\business_rules\ControllerCode
public function modal($collection, $key, $title, $method) {
$keyvalue = $this->util
->getKeyValueExpirable($collection);
$content = $keyvalue
->get($key);
if ($method == 'ajax') {
$content['#attached']['library'][] = 'core/drupal.dialog.ajax';
$options = [
'width' => '75%',
];
$response = new AjaxResponse();
$response
->addCommand(new OpenModalDialogCommand($title, $content, $options));
return $response;
}
else {
return $content;
}
}