The documentation in 7.x-1.5 incorrectly suggests that FacetapiAdapter::getActiveItems() can accept the $facet argument as either a string or an array. I see the documentation has been fixed on the dev branch as part of https://www.drupal.org/node/2563117, but it actually seems like a useful feature to allow passing the facet name as a string (why go to the trouble of loading a facet with facetapi_facet_load() when it's not necessary?).

Comments

remydenton created an issue. See original summary.

remydenton’s picture

Status: Active » Needs review
StatusFileSize
new1.08 KB
eugene.ilyin’s picture

Hello.

Could you explain the case when it can be a string, please?

eugene.ilyin’s picture

Status: Needs review » Postponed (maintainer needs more info)
remydenton’s picture

Status: Postponed (maintainer needs more info) » Needs review

My use case was in theme preprocessing-- I wanted to know whether there was an active item for a given facet so that we could expand that particular facet block with javascript for small devices. In the preprocess function for the panels pane I was using, it was easy to find the machine name of the facet. But then in order to figure out whether it was active, I additionally had to use `facetapi_facet_load()` to load the facet.

Basically, it seemed silly that I had to do this:

$facet = facetapi_facet_load('my_facet_name');
$adapter->getActiveItems($facet);

When I could have just done this if the documentation for getActiveItems() had been correct :

$adapter->getActiveItems('my_facet_name');
remydenton’s picture

Actually, on second glance, it's even more complicated than that-- you also need to pass a $searcher parameter to facetapi_facet_load().