You are here

public function ModalController::modal in Business Rules 2.x

Same name and namespace in other branches
  1. 8 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'
business_rules.routing.yml in ./business_rules.routing.yml
business_rules.routing.yml

File

src/Controller/ModalController.php, line 55

Class

ModalController
Class HelpController.

Namespace

Drupal\business_rules\Controller

Code

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;
  }
}