You are here

public function UrlProcessorHandler::__construct in Facets 8

Constructs a \Drupal\Component\Plugin\PluginBase object.

Parameters

array $configuration: A configuration array containing information about the plugin instance.

string $plugin_id: The plugin_id for the plugin instance.

mixed $plugin_definition: The plugin implementation definition.

Overrides PluginBase::__construct

File

src/Plugin/facets/processor/UrlProcessorHandler.php, line 52

Class

UrlProcessorHandler
The URL processor handler triggers the actual url processor.

Namespace

Drupal\facets\Plugin\facets\processor

Code

public function __construct(array $configuration, $plugin_id, array $plugin_definition) {
  parent::__construct($configuration, $plugin_id, $plugin_definition);
  if (!isset($configuration['facet']) || !$configuration['facet'] instanceof FacetInterface) {
    throw new InvalidProcessorException("The UrlProcessorHandler doesn't have the required 'facet' in the configuration array.");
  }

  /** @var \Drupal\facets\FacetInterface $facet */
  $facet = $configuration['facet'];

  /** @var \Drupal\facets\FacetSourceInterface $fs */
  $fs = $facet
    ->getFacetSourceConfig();
  $url_processor_name = $fs
    ->getUrlProcessorName();
  $manager = \Drupal::getContainer()
    ->get('plugin.manager.facets.url_processor');
  $this->processor = $manager
    ->createInstance($url_processor_name, [
    'facet' => $facet,
  ]);
}