예제 #1
0
 /**
  * Retrieve all unique values for the given property.
  *
  * The result set will be an array containing all unique values contained in the data provider.
  * 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 InterfaceGeneralDataConfig $objConfig   The filter config options.
  *
  * @return GeneralCollectionDefault
  *
  * @throws Exception if improper values have been passed (i.e. not exactly one field requested).
  */
 public function getFilterOptions(InterfaceGeneralDataConfig $objConfig)
 {
     $arrProperties = $objConfig->getFields();
     $strProperty = $arrProperties[0];
     if (count($arrProperties) != 1) {
         throw new Exception('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 = $this->getEmptyCollection();
     while ($objValues->next()) {
         $objNewModel = $this->getEmptyModel();
         $objNewModel->setProperty($strProperty, $objValues->{$strProperty});
         $objCollection->add($objNewModel);
     }
     return $objCollection;
 }
 /**
  * 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 InterfaceGeneralDataConfig $objConfig   The filter config options.
  *
  * @return InterfaceGeneralCollection
  *
  * @throws Exception if improper values have been passed (i.e. not exactly one field requested).
  */
 public function getFilterOptions(InterfaceGeneralDataConfig $objConfig)
 {
     $arrProperties = $objConfig->getFields();
     if (count($arrProperties) != 1) {
         throw new Exception('objConfig must contain exactly one property to be retrieved.');
     }
     $objFilter = $this->prepareFilter($objConfig->getFilter());
     $arrValues = $this->objMetaModel->getAttribute($arrProperties[0])->getFilterOptions($objFilter->getMatchingIds(), true);
     $objCollection = $this->getEmptyCollection();
     foreach ($arrValues as $strValue) {
         $objNewModel = $this->getEmptyModel();
         $objNewModel->setProperty($arrProperties[0], $strValue);
         $objCollection->add($objNewModel);
     }
     return $objCollection;
 }