You are here

public function Facet::getFacetSource in Facets 8

Returns the plugin instance of a facet source.

Return value

\Drupal\facets\FacetSource\FacetSourcePluginInterface|null The plugin instance for the facet source.

Overrides FacetInterface::getFacetSource

2 calls to Facet::getFacetSource()
Facet::calculateDependencies in src/Entity/Facet.php
Calculates dependencies and stores them in the dependency property.
Facet::getQueryType in src/Entity/Facet.php
Returns the query type instance.

File

src/Entity/Facet.php, line 713

Class

Facet
Defines the facet configuration entity.

Namespace

Drupal\facets\Entity

Code

public function getFacetSource() {
  if (is_null($this->facet_source_instance) && $this->facet_source_id) {

    /* @var $facet_source_plugin_manager \Drupal\facets\FacetSource\FacetSourcePluginManager */
    $facet_source_plugin_manager = \Drupal::service('plugin.manager.facets.facet_source');
    if (!$facet_source_plugin_manager
      ->hasDefinition($this->facet_source_id)) {
      return NULL;
    }
    $this->facet_source_instance = $facet_source_plugin_manager
      ->createInstance($this->facet_source_id, [
      'facet' => $this,
    ]);
  }
  return $this->facet_source_instance;
}