You are here

public function FacetSourcePluginManager::processDefinition in Facets 8

Performs extra processing on plugin definitions.

By default we add defaults for the type to the definition. If a type has additional processing logic they can do that by replacing or extending the method.

Overrides DefaultPluginManager::processDefinition

File

src/FacetSource/FacetSourcePluginManager.php, line 32

Class

FacetSourcePluginManager
Manages facet source plugins.

Namespace

Drupal\facets\FacetSource

Code

public function processDefinition(&$definition, $plugin_id) {
  parent::processDefinition($definition, $plugin_id);

  // At the very least - we need to have an ID in the definition of the
  // plugin.
  if (!isset($definition['id'])) {
    throw new PluginException(sprintf('The facet source plugin %s must define the id property.', $plugin_id));
  }

  // If we're checking the search api plugin, only try to add it if search api
  // is enabled.
  if ($definition['id'] === 'search_api' && !$this->moduleHandler
    ->moduleExists('search_api')) {
    return;
  }

  // Check that other required labels are available.
  foreach ([
    'display_id',
    'label',
  ] as $required_property) {
    if (empty($definition[$required_property])) {
      throw new PluginException(sprintf('The facet source plugin %s must define the %s property.', $plugin_id, $required_property));
    }
  }
}