You are here

public function UrlProcessorPluginBase::__construct in Facets 8

Constructs a new instance of the class.

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.

\Symfony\Component\HttpFoundation\Request $request: A request object for the current request.

\Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager: The Entity Type Manager.

Throws

\Drupal\facets\Exception\InvalidProcessorException

Overrides PluginBase::__construct

1 call to UrlProcessorPluginBase::__construct()
QueryString::__construct in src/Plugin/facets/url_processor/QueryString.php
Constructs a new instance of the class.
1 method overrides UrlProcessorPluginBase::__construct()
QueryString::__construct in src/Plugin/facets/url_processor/QueryString.php
Constructs a new instance of the class.

File

src/UrlProcessor/UrlProcessorPluginBase.php, line 87

Class

UrlProcessorPluginBase
A base class for plugins that implements most of the boilerplate.

Namespace

Drupal\facets\UrlProcessor

Code

public function __construct(array $configuration, $plugin_id, $plugin_definition, Request $request, EntityTypeManagerInterface $entity_type_manager) {
  parent::__construct($configuration, $plugin_id, $plugin_definition);
  $this->request = clone $request;
  $this->entityTypeManager = $entity_type_manager;
  if (!isset($configuration['facet'])) {
    throw new InvalidProcessorException("The url processor doesn't have the required 'facet' in the configuration array.");
  }

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

  /** @var \Drupal\facets\FacetSourceInterface $facet_source_config */
  $facet_source_config = $facet
    ->getFacetSourceConfig();
  $this->filterKey = $facet_source_config
    ->getFilterKey() ?: 'f';

  // Set the separator to the predefined colon char but override if passed
  // along as part of the plugin configuration.
  $this->separator = ':';
  if (isset($configuration['separator'])) {
    $this->separator = $configuration['separator'];
  }
}