You are here

protected function AjaxResponseSubscriber::alterCommands in Geolocation Field 8

Alter the views AJAX response commands only for the map.

Parameters

array $commands: An array of commands to alter.

File

src/EventSubscriber/AjaxResponseSubscriber.php, line 21

Class

AjaxResponseSubscriber
Response subscriber to handle AJAX responses.

Namespace

Drupal\geolocation\EventSubscriber

Code

protected function alterCommands(array &$commands) {
  foreach ($commands as $delta => &$command) {

    // Substitute the 'replace' method without our custom jQuery method which
    // will allow views content to be injected one after the other.
    if (isset($command['method']) && $command['method'] === 'replaceWith' && isset($command['selector']) && substr($command['selector'], 0, 16) === '.js-view-dom-id-') {
      $command['command'] = 'geolocationCommonMapsUpdate';
      unset($command['method']);
    }
  }
}