diff --git a/src/Annotation/FacetsHierarchy.php b/src/Annotation/FacetsHierarchy.php index d5f82cd..d3ec151 100644 --- a/src/Annotation/FacetsHierarchy.php +++ b/src/Annotation/FacetsHierarchy.php @@ -7,7 +7,7 @@ use Drupal\Component\Annotation\Plugin; /** * Defines a Facets Hierarchy annotation. * - * @see \Drupal\facets\Processor\ProcessorPluginManager + * @see \Drupal\facets\Hierarchy\HierarchyPluginManager * @see plugin_api * * @ingroup plugin_api diff --git a/src/FacetManager/DefaultFacetManager.php b/src/FacetManager/DefaultFacetManager.php index 6abc8ae..b623d37 100644 --- a/src/FacetManager/DefaultFacetManager.php +++ b/src/FacetManager/DefaultFacetManager.php @@ -389,6 +389,21 @@ class DefaultFacetManager { return !empty($this->facets[$facet->id()]) ? $this->facets[$facet->id()] : NULL; } + /** + * Builds an hierarchical structure for results. + * + * When given an array of results and an array which defines the hierarchical + * structure, this will build the results structure and set all childs. + * + * @param \Drupal\facets\Result\ResultInterface[] + * An array of results keyed by id. + * + * @param array + * An array of 'child id arrays' keyed by their parent id. + * + * @return \Drupal\facets\Result\ResultInterface[] + * An array of results structured hierarchicaly. + */ protected function buildHierarchicalTree($keyed_results, $parent_groups) { foreach ($keyed_results as &$result) { $current_id = $result->getRawValue(); diff --git a/src/Hierarchy/HierarchyInterface.php b/src/Hierarchy/HierarchyInterface.php index b67147b..b7c367c 100644 --- a/src/Hierarchy/HierarchyInterface.php +++ b/src/Hierarchy/HierarchyInterface.php @@ -5,8 +5,26 @@ namespace Drupal\facets\Hierarchy; interface HierarchyInterface { + /** + * Retrieve all parent ids for one specific id. + * + * @param string $id + * An entity id. + * + * @return array + * An array of all parent ids. + */ public function getParentIds($id); + /** + * Retrieve all children and nested children for one specific id. + * + * @param string $id + * An entity id. + * + * @return array + * An array of all child ids. + */ public function getNestedChildIds($id); /**