MetaModels\DcGeneral\Data\Driver::getFilterOptions PHP Method

getFilterOptions() public method

The result set will be an array containing all unique values contained in the MetaModel for the defined attribute in the configuration. Note: this only re-ensembles really used values for at least one data set. The only information being interpreted from the passed config object is the first property to fetch and the filter definition.
public getFilterOptions ( ContaoCommunityAlliance\DcGeneral\Data\ConfigInterface $objConfig ) : ContaoCommunityAlliance\DcGeneral\Data\FilterOptionCollectionInterface
$objConfig ContaoCommunityAlliance\DcGeneral\Data\ConfigInterface The filter config options.
return ContaoCommunityAlliance\DcGeneral\Data\FilterOptionCollectionInterface
    public function getFilterOptions(ConfigInterface $objConfig)
    {
        $arrProperties = $objConfig->getFields();
        if (count($arrProperties) != 1) {
            throw new \RuntimeException('objConfig must contain exactly one property to be retrieved.');
        }
        $objFilter = $this->prepareFilter($objConfig);
        $arrValues = $this->getMetaModel()->getAttribute($arrProperties[0])->getFilterOptions($objFilter->getMatchingIds(), true);
        $objCollection = new DefaultFilterOptionCollection();
        foreach ($arrValues as $strKey => $strValue) {
            $objCollection->add($strKey, $strValue);
        }
        return $objCollection;
    }