You are here

public function AcquiaPurgeProcessorsService::emit in Acquia Purge 7

Emit a particular event.

Parameters

string $event: Name of the event, often derived from hook implementations found directly in acquia_purge.module, but could also be 'onItemsQueued'.

mixed $a1: First optional parameter to pass by reference.

mixed $a2: Second optional parameter to pass by reference.

File

lib/processor/AcquiaPurgeProcessorsService.php, line 86
Contains AcquiaPurgeProcessorsService.

Class

AcquiaPurgeProcessorsService
Service that loads and bundles queue processor backends.

Code

public function emit($event, &$a1 = NULL, &$a2 = NULL) {

  // Don't emit when there are no subscribers.
  if (!isset($this->events[$event])) {
    return;
  }

  // Emit to subscribed processors and pass on any given parameters.
  if (isset($this->events[$event])) {
    foreach ($this->events[$event] as $processor) {
      if (is_null($a1)) {
        $processor
          ->{$event}();
      }
      elseif (is_null($a2)) {
        $processor
          ->{$event}($a1);
      }
      else {
        $processor
          ->{$event}($a1, $a2);
      }
    }
  }
}