Chris@0: $title]; Chris@0: $this->selector = $selector; Chris@0: $this->content = $content; Chris@0: $this->dialogOptions = $dialog_options; Chris@0: $this->settings = $settings; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns the dialog options. Chris@0: * Chris@0: * @return array Chris@0: */ Chris@0: public function getDialogOptions() { Chris@0: return $this->dialogOptions; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Sets the dialog options array. Chris@0: * Chris@0: * @param array $dialog_options Chris@0: * Options to be passed to the dialog implementation. Any jQuery UI option Chris@0: * can be used. See http://api.jqueryui.com/dialog. Chris@0: */ Chris@0: public function setDialogOptions($dialog_options) { Chris@0: $this->dialogOptions = $dialog_options; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Sets a single dialog option value. Chris@0: * Chris@0: * @param string $key Chris@0: * Key of the dialog option. Any jQuery UI option can be used. Chris@0: * See http://api.jqueryui.com/dialog. Chris@0: * @param mixed $value Chris@0: * Option to be passed to the dialog implementation. Chris@0: */ Chris@0: public function setDialogOption($key, $value) { Chris@0: $this->dialogOptions[$key] = $value; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Sets the dialog title (an alias of setDialogOptions). Chris@0: * Chris@0: * @param string $title Chris@0: * The new title of the dialog. Chris@0: */ Chris@0: public function setDialogTitle($title) { Chris@12: $this->setDialogOption('title', $title); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Implements \Drupal\Core\Ajax\CommandInterface:render(). Chris@0: */ Chris@0: public function render() { Chris@0: // For consistency ensure the modal option is set to TRUE or FALSE. Chris@0: $this->dialogOptions['modal'] = isset($this->dialogOptions['modal']) && $this->dialogOptions['modal']; Chris@0: return [ Chris@0: 'command' => 'openDialog', Chris@0: 'selector' => $this->selector, Chris@0: 'settings' => $this->settings, Chris@0: 'data' => $this->getRenderedContent(), Chris@0: 'dialogOptions' => $this->dialogOptions, Chris@0: ]; Chris@0: } Chris@0: Chris@0: }