You are here

public function Facet::setHierarchy in Facets 8

Sets the facet hierarchy definition.

Parameters

string $id: The hierarchy plugin id.

array $configuration: (optional) The facet hierarchy plugin configuration. When empty, the default plugin configuration will be used.

Overrides FacetInterface::setHierarchy

File

src/Entity/Facet.php, line 376

Class

Facet
Defines the facet configuration entity.

Namespace

Drupal\facets\Entity

Code

public function setHierarchy($id, array $configuration = NULL) {
  if ($configuration === NULL) {
    $instance = $this
      ->getHierarchyManager()
      ->createInstance($id);

    // Get the default configuration for this plugin.
    $configuration = $instance
      ->getConfiguration();
  }
  $this->hierarchy = [
    'type' => $id,
    'config' => $configuration,
  ];

  // Unset the hierarchy instance, if exists.
  unset($this->hierarchy_instance);
}