I'm working on a custom block that outputs information from facets and have them mostly working, but I don't understand why getActiveItems is returning empty:
<?php
$facet_manager = \Drupal::service('facets.manager');
$facet_storage = \Drupal::entityManager()->getStorage('facets_facet');
$facet = $facet_storage->load($facet_id);
$items = $facet_manager->build($facet);
// works and I can loop through the results
ksm($facet->getActiveItems());
// this doesn't work, it returns an empty array
// I looked at the breadcrumb stuff in facets.module, but didn't get it still
?>
Comments
Comment #2
ddomee commentedI had the same problem, you were only missing one line:
Comment #3
borisson_Thanks for helping to fix this support request @ddomee.
Comment #5
fmb commentedFor whatever reason, returnProcessedFacet() returned NULL for me, so I ended up using this code :