/**
  * @param MetaModelsFilterCollection $filter
  * @return array
  */
 private function createFilterParams(MetaModelsFilterCollection $filter)
 {
     $names = $filter->getParameterFilterNames();
     $values = array();
     foreach (array_keys($names) as $name) {
         $varValue = \Input::get($name);
         if (is_string($varValue)) {
             $values[$name] = $varValue;
         }
     }
     return $values;
 }
Example #2
0
 /**
  * Set parameters.
  *
  * @param string[] $arrPresets The parameter preset values to use.
  *
  * @param string[] $arrValues  The dynamic parameter values that may be used.
  *
  * @return ItemList
  *
  * @throws \RuntimeException When no filter settings have been set.
  */
 public function setFilterParameters($arrPresets, $arrValues)
 {
     if (!$this->objFilterSettings) {
         throw new \RuntimeException('Error: no filter object defined, call setFilterSettings() before setFilterParameters().');
     }
     $arrPresetNames = $this->objFilterSettings->getParameters();
     $arrFEFilterParams = array_keys($this->objFilterSettings->getParameterFilterNames());
     $arrProcessed = array();
     // We have to use all the preset values we want first.
     foreach ($arrPresets as $strPresetName => $arrPreset) {
         if (in_array($strPresetName, $arrPresetNames)) {
             $arrProcessed[$strPresetName] = $arrPreset['value'];
         }
     }
     // Now we have to use all FE filter params, that are either:
     // * not contained within the presets
     // * or are overridable.
     foreach ($arrFEFilterParams as $strParameter) {
         // Unknown parameter? - next please.
         if (!array_key_exists($strParameter, $arrValues)) {
             continue;
         }
         // Not a preset or allowed to override? - use value.
         if (!array_key_exists($strParameter, $arrPresets) || $arrPresets[$strParameter]['use_get']) {
             $arrProcessed[$strParameter] = $arrValues[$strParameter];
         }
     }
     $this->arrParam = $arrProcessed;
     return $this;
 }
 /**
  * Retrieve all filter parameters from the input class for the specified filter setting.
  *
  * @param ICollection $filterSettings The filter settings.
  *
  * @return string[]
  */
 protected function getFilterParameters(ICollection $filterSettings)
 {
     $params = array();
     foreach (array_keys($filterSettings->getParameterFilterNames()) as $strName) {
         $varValue = \Input::getInstance()->get($strName);
         if (is_string($varValue)) {
             $params[$strName] = $varValue;
         }
     }
     return $params;
 }