You are here

protected function FacetsSummary::loadProcessors in Facets 8

Retrieves all processors supported by this facets summary.

Return value

\Drupal\facets_summary\Processor\ProcessorInterface[] The loaded processors, keyed by processor ID.

1 call to FacetsSummary::loadProcessors()
FacetsSummary::getProcessors in modules/facets_summary/src/Entity/FacetsSummary.php
Returns an array of processors with their configuration.

File

modules/facets_summary/src/Entity/FacetsSummary.php, line 176

Class

FacetsSummary
Defines the facet summary entity.

Namespace

Drupal\facets_summary\Entity

Code

protected function loadProcessors() {
  if (is_array($this->processors)) {
    return $this->processors;
  }

  /* @var $processor_plugin_manager \Drupal\facets\Processor\ProcessorPluginManager */
  $processor_plugin_manager = \Drupal::service('plugin.manager.facets_summary.processor');
  $processor_settings = $this
    ->getProcessorConfigs();
  foreach ($processor_plugin_manager
    ->getDefinitions() as $name => $processor_definition) {
    if (class_exists($processor_definition['class']) && empty($this->processors[$name])) {

      // Create our settings for this processor.
      $settings = empty($processor_settings[$name]['settings']) ? [] : $processor_settings[$name]['settings'];
      $settings['facets_summary'] = $this;

      /* @var $processor \Drupal\facets_summary\Processor\ProcessorInterface */
      $processor = $processor_plugin_manager
        ->createInstance($name, $settings);
      $this->processors[$name] = $processor;
    }
    elseif (!class_exists($processor_definition['class'])) {
      \Drupal::logger('facets_summary')
        ->warning('Processor @id specifies a non-existing @class.', [
        '@id' => $name,
        '@class' => $processor_definition['class'],
      ]);
    }
  }
  return $this->processors;
}