You are here

public function AcquiaPurgeProcessorsService::__construct in Acquia Purge 7

Construct a new AcquiaPurgeProcessorsService instance.

Parameters

AcquiaPurgeService $service: The Acquia Purge service object.

File

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

Class

AcquiaPurgeProcessorsService
Service that loads and bundles queue processor backends.

Code

public function __construct(AcquiaPurgeService $service) {
  $this->service = $service;
  _acquia_purge_load('_acquia_purge_processor_interface');
  _acquia_purge_load('_acquia_purge_processor_base');

  // Initialize the processors that advertize themselves as enabled.
  foreach ($this->backends as $service) {
    $class = _acquia_purge_load($service);
    if ($class::isEnabled()) {
      $this->processors[$class] = new $class($this->service);
    }
  }

  // Query the enabled processors for their subscribed events.
  foreach ($this->processors as $processor) {
    foreach ($processor
      ->getSubscribedEvents() as $event) {
      if (!isset($this->events[$event])) {
        $this->events[$event] = array();
      }
      $this->events[$event][] = $processor;
    }
  }
}