You are here

protected function Facet::loadProcessors in Facets 8

Retrieves all processors supported by this facet.

Return value

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

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

File

src/Entity/Facet.php, line 415

Class

Facet
Defines the facet configuration entity.

Namespace

Drupal\facets\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.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['facet'] = $this;

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