Example #1
0
 /**
  * Retrieve all unique values for the given property.
  *
  * 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.
  *
  * @param ConfigInterface $objConfig The filter config options.
  *
  * @return FilterOptionCollectionInterface
  *
  * @throws \RuntimeException If improper values have been passed (i.e. not exactly one field requested).
  */
 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;
 }
 /**
  * {@inheritdoc}
  */
 public function getFilterOptions(ConfigInterface $config)
 {
     $properties = $config->getFields();
     $property = $properties[0];
     if (count($properties) != 1) {
         throw new \Exception('Config must contain exactly one property to be retrieved.');
     }
     $entityManager = $this->getEntityManager();
     $queryBuilder = $entityManager->createQueryBuilder();
     $values = $queryBuilder->select('DISTINCT e.' . $property)->from($this->entityClassName, 'e')->orderBy('e.' . $property)->getQuery()->getResult();
     $collection = new DefaultFilterOptionCollection();
     if ($values) {
         foreach ($values as $value) {
             $collection->add($value[$property], $value[$property]);
         }
     }
     return $collection;
 }
 /**
  * {@inheritDoc}
  *
  * @throws DcGeneralRuntimeException If improper values have been passed (i.e. not exactly one field requested).
  */
 public function getFilterOptions(ConfigInterface $objConfig)
 {
     $arrProperties = $objConfig->getFields();
     $strProperty = $arrProperties[0];
     if (count($arrProperties) != 1) {
         throw new DcGeneralRuntimeException('objConfig must contain exactly one property to be retrieved.');
     }
     $arrParams = array();
     $objValues = $this->objDatabase->prepare(sprintf('SELECT DISTINCT(%s) FROM %s %s', $strProperty, $this->strSource, $this->buildWhereQuery($objConfig, $arrParams)))->execute($arrParams);
     $objCollection = new DefaultFilterOptionCollection();
     while ($objValues->next()) {
         $objCollection->add($objValues->{$strProperty}, $objValues->{$strProperty});
     }
     return $objCollection;
 }