diff --git a/core/lib/Drupal/Core/Ajax/InsertCommand.php b/core/lib/Drupal/Core/Ajax/InsertCommand.php index 8c0e938..f11149c 100644 --- a/core/lib/Drupal/Core/Ajax/InsertCommand.php +++ b/core/lib/Drupal/Core/Ajax/InsertCommand.php @@ -46,6 +46,16 @@ class InsertCommand implements CommandInterface { protected $settings; /** + * An array of additional data to add to the command's render() output. + * + * @todo Remove this in favor of a better solution for providing the title to + * the modal dialog. + * + * @var array + */ + protected $additionalOutput; + + /** * Constructs an InsertCommand object. * * @param string $selector @@ -55,10 +65,11 @@ class InsertCommand implements CommandInterface { * @param array $settings * An array of JavaScript settings to be passed to any attached behaviors. */ - public function __construct($selector, $html, array $settings = NULL) { + public function __construct($selector, $html, array $settings = NULL, $additional_output = array()) { $this->selector = $selector; $this->html = $html; $this->settings = $settings; + $this->additionalOutput = $additional_output; } /** @@ -66,13 +77,14 @@ public function __construct($selector, $html, array $settings = NULL) { */ public function render() { - return array( + $output = array( 'command' => 'insert', 'method' => NULL, 'selector' => $this->selector, 'data' => $this->html, 'settings' => $this->settings, ); + return $output + $this->additionalOutput; } } diff --git a/core/lib/Drupal/Core/AjaxController.php b/core/lib/Drupal/Core/AjaxController.php index 31259fb..a69a26b 100644 --- a/core/lib/Drupal/Core/AjaxController.php +++ b/core/lib/Drupal/Core/AjaxController.php @@ -65,7 +65,7 @@ public function content(Request $request, $_content) { // The selector for the insert command is NULL as the new content will // replace the element making the ajax call. The default 'replaceWith' // behavior can be changed with #ajax['method']. - $response->addCommand(new InsertCommand(NULL, $html)); + $response->addCommand(new InsertCommand(NULL, $html, NULL, array('title' => drupal_get_title()))); $status_messages = theme('status_messages'); if (!empty($status_messages)) { $response->addCommand(new PrependCommand(NULL, $status_messages));