You are here

public function CollectEvent::getDrupalSettingCommands in Googalytics - Google Analytics 8

Format the commands for use in drupalSettings.

Return value

array An array of commands for use in drupalSettings.

File

src/Event/CollectEvent.php, line 43

Class

CollectEvent
Class CollectEvent.

Namespace

Drupal\ga\Event

Code

public function getDrupalSettingCommands() {
  usort($this->commands, function (DrupalSettingCommandsInterface $a, DrupalSettingCommandsInterface $b) {
    return $b
      ->getPriority() - $a
      ->getPriority();
  });
  return array_reduce($this->commands, function ($carry, DrupalSettingCommandsInterface $item) {
    return array_merge($carry, $item
      ->getSettingCommands());
  }, []);
}