public function RefreshPageElementsHelper::updateStatusMessages in Commerce Ajax Add to Cart 8
Refreshes status messages.
Return value
$this
File
- src/
RefreshPageElementsHelper.php, line 112
Class
- RefreshPageElementsHelper
- Provides methods that would help in refreshing certain page elements.
Namespace
Drupal\dc_ajax_add_cartCode
public function updateStatusMessages() {
$block_id = $this
->getStatusMessagesBlockId();
if ($block_id) {
/** @var \Drupal\block\BlockInterface $block */
$block = Block::load($block_id);
$elements = [
'#type' => 'status_messages',
];
$this->response
->addCommand(new RemoveCommand('.messages__wrapper'));
$this->response
->addCommand(new AppendCommand(".region-{$block->getRegion()}", $this->renderer
->renderRoot($elements)));
}
return $this;
}