Load filter dependencies into model and populate the filterOptions

@return array filterClassName => Label
19579
protected function loadFilterDependencies($activateDependencies = true)
    {
        if (! $this->filterOptions) {
            $maxLength = $this->get('gaf_calc_name', 'maxlength');

            $this->filterOptions = array();
            foreach ($this->filterDependencies as $dependencyClass) {
                $dependency = $this->agenda->newFilterObject($dependencyClass);
                if ($dependency instanceof FilterModelDependencyAbstract) {

                    $this->filterOptions[$dependency->getFilterClass()] = $dependency->getFilterName();

                    if ($activateDependencies) {
                        $dependency->setMaximumCalcLength($maxLength);
                        $this->addDependency($dependency);
                    }
                }
            }
            asort($this->filterOptions);
        }

        return $this->filterOptions;
    }
74275
protected function getFilterArray()
    {
        return array_merge(parent::getFilterArray(), [
      self::ARGUMENT_FILTER_OFFSET => $this->arguments[self::ARGUMENT_FILTER_OFFSET],
      self::ARGUMENT_FILTER_LIMIT => $this->arguments[self::ARGUMENT_FILTER_LIMIT],
      self::ARGUMENT_FILTER_TYPES => $this->arguments[self::ARGUMENT_FILTER_TYPES],
      self::ARGUMENT_FILTER_NAME => $this->arguments[self::ARGUMENT_FILTER_NAME],
      self::ARGUMENT_FILTER_CATEGORYID => $this->arguments[self::ARGUMENT_FILTER_CATEGORYID],
      self::ARGUMENT_FILTER_REPERTOIREID => $this->arguments[self::ARGUMENT_FILTER_REPERTOIREID],
      self::ARGUMENT_FILTER_LOCATION => $this->arguments[self::ARGUMENT_FILTER_LOCATION]
    ]);
    }
1088622
public function getFilters()
    {
        $filters = [
            new Twig_SimpleFilter('app', [$this, 'appFilter'], ['is_safe' => ['html']]),
            new Twig_SimpleFilter('media', [$this, 'mediaFilter'], ['is_safe' => ['html']]),
        ];

        /*
         * Include extensions provided by plugins
         */
        $filters = $this->markupManager->makeTwigFilters($filters);

        return $filters;
    }
1083048
public function getFilters()
    {
        $filters = [];

        $names = explode('_', $this->name);
        $base = '';
        $filters = [];
        while ($name = array_shift($names)) {
            $filter = $this->_searchInControllerDir($base, 'filter.yml');
            if ($filter) $filters[] = $filter;

            // when has rest.
            if (count($names) > 0) {
                $base = $base . DS . ucfirst($name);

            // when last.
            } else {
                $filter = $this->_searchInControllerDir($base, "{$name}.filter.yml");
                if ($filter) $filters[] = $filter;
            }
        }

        return $filters;
    }
999998
public function getFilters()
    {
        if ($this->progressive) {
            $fc = new FilterChain();
            $fc->add(new Interlace(ImageInterface::INTERLACE_PLANE));
            return $fc;
        } else {
            return null;
        }
    }
599761
private function initFilters(array $filters)
    {
    	$result = array();
    
    	$fm = $this->getFilterManager();
    
    	foreach ($filters as $alias => $options) {
    		$option = null;
    		if (is_array($options)) {
    			if (!isset($options['name'])) {
    				throw new Exception\InvalidArgumentException(
    						'Filter "' . $alias . '" required option "name"'
    				);
    			}
    
    			$name = $options['name'];
    			$option = isset($options['option']) ? $options['option'] : null;
    		} elseif (is_string($options)) {
    			$name = $options;
    			unset($options);
    		}
    
    		if (is_numeric($alias)) {
    			$alias = $name;
    		}
    
    		// Filter Id should have optional filter indicator "?"
    		$filterId = ltrim($alias, '?');
    
    		if (!$fm->has($filterId)) {
    			if (is_array($option) && !empty($option)) {
    				$r = new \ReflectionClass($name);
    				$filter = $r->newInstanceArgs($option);
    			} else if ($option) {
    				$filter = new $name($option);
    			} else {
    				$filter = new $name();
    			}
    
    			$fm->set($filterId, $filter);
    		}
    
    		$result[] = $alias;
    	}
    
    	return $result;
    }
1168152
public static function loadFilters() {
		
		// load defaults
		$filterDir = Config::getOption("sourceDir").DIRECTORY_SEPARATOR."_twig-components/filters";
		$filterExt = Config::getOption("twigFilterExt");
		$filterExt = $filterExt ? $filterExt : "filter.php";
		
		if (is_dir($filterDir)) {
			
			// loop through the filter dir...
			$finder = new Finder();
			$finder->files()->name("*\.".$filterExt)->in($filterDir);
			$finder->sortByName();
			foreach ($finder as $file) {
				
				// see if the file should be ignored or not
				$baseName = $file->getBasename();
				if ($baseName[0] != "_") {
					
					include($file->getPathname());
					
					// $filter should be defined in the included file
					if (isset($filter)) {
						self::$instance->addFilter($filter);
						unset($filter);
					}
					
				}
				
			}
			
		}
		
	}
257744
protected function getFilters()
    {
        $filters = array_diff(get_class_methods($this), [
            '__construct', '__call', 'apply', 'getFilters', 'getSearchables', 'getSortables', 'buildSearch', 'buildSql'
        ]);
        $filters = array_merge($filters, array_map(function ($searchable, $key) {
            return is_array($searchable) ? $key : $searchable;
        }, $this->searchables, array_keys($this->searchables)));

        return array_only($this->request->query(), $filters);
    }
365415
public function generateFilter() : array {
		$result = [];
		// filter
		foreach ($this->fields as $k => $v) {
			if ($v['options']['container_link'] != 'filter') continue;
			if (($v['options']['method'] ?? null) == 'hidden') continue;
			$label = i18n(null, $v['options']['label_name']);
			$value = $this->values[$k] ?? null;
			if (!empty($v['options']['options_model'])) {
				$value = $this->renderListContainerDefaultOptions($v['options'], $value, $this->values);
			}
			if (is_array($value)) {
				$value = implode(', ', $value);
			}
			if (!isset($result[$label])) {
				$result[$label] = $value;
			} else {
				$result[$label].= ' - ' . $value;
			}
		}
		// sort
		if (!empty($this->values['\Object\Form\Model\Dummy\Sort'])) {
			$sort_options = \Object\Data\Model\Order::optionsStatic(['i18n' => true]);
			$temp = [];
			foreach ($this->values['\Object\Form\Model\Dummy\Sort'] as $k => $v) {
				$name = $this->detail_fields['\Object\Form\Model\Dummy\Sort']['elements']['__sort']['options']['options'][$v['__sort']]['name'];
				$temp[] = i18n(null, $name) . ' ' . $sort_options[$v['__order']]['name'];
			}
			$result[i18n(null, 'Sort')] = implode(', ', $temp);
		}
		return $result;
	}
1077385
private function addDependencyOperations() {
    $operations = [];

    foreach ($this->dependencies as $module => $type) {
      $operations[] = [
        [static::class, 'installDependency'],
        [
          $module,
          $type,
        ],
      ];
    }

    return $operations;
  }
205592
private function load()
    {
        if ($this->loaded) {
            return;
        }

        $models = (array) $this->query->find();

        $preferred = array();
        if ($this->preferredQuery instanceof \ModelCriteria) {
            $preferred = (array) $this->preferredQuery->find();
        }

        try {
            // The second parameter $labels is ignored by ObjectChoiceList
            parent::initialize($models, array(), $preferred);

            $this->loaded = true;
        } catch (StringCastException $e) {
            throw new StringCastException(str_replace('argument $labelPath', 'option "property"', $e->getMessage()), null, $e);
        }
    }
770350
public function applyBrowseSettings()
    {
        $this->loadFilterDependencies(false);

        $yesNo = $this->util->getTranslated()->getYesNo();

        $this->set('gaf_class', 'label', $this->_('Filter type'),
                'description', $this->_('Determines what is filtered how.'),
                'multiOptions', $this->filterOptions
                );
        $this->addColumn('COALESCE(gaf_manual_name, gaf_calc_name)', 'gaf_name');
        $this->set('gaf_name', 'label', $this->_('Name'));
        $this->set('gaf_id_order', 'label', $this->_('Order'),
                'description', $this->_('Execution order of the filters, lower numbers are executed first.')
                );
        $this->set('gaf_active', 'label', $this->_('Active'),
                'multiOptions', $yesNo
                );

        $this->addColumn(new \Zend_Db_Expr(
                "(SELECT COUNT(*) FROM gems__track_appointments WHERE gaf_id = gtap_filter_id)"
                ), 'usetrack');
        $this->set('usetrack', 'label', $this->_('Use in track fields'),
                'description', $this->_('The number of uses of this filter in track fields.'),
                'elementClass', 'Exhibitor'
                );
        $this->addColumn(new \Zend_Db_Expr(
                "(SELECT COUNT(*)
                    FROM gems__appointment_filters AS other
                    WHERE gaf_class IN ('AndAppointmentFilter', 'OrAppointmentFilter') AND
                        (
                            gems__appointment_filters.gaf_id = other.gaf_filter_text1 OR
                            gems__appointment_filters.gaf_id = other.gaf_filter_text2 OR
                            gems__appointment_filters.gaf_id = other.gaf_filter_text3 OR
                            gems__appointment_filters.gaf_id = other.gaf_filter_text4
                        )
                )"
                ), 'usefilter');
        $this->set('usefilter', 'label', $this->_('Use in filters'),
                'description', $this->_('The number of uses of this filter in other filters.'),
                'elementClass', 'Exhibitor'
                );


        return $this;
    }
96843
protected function initFilters()
    {
        // If override status is set in field options to true
        // we will change filtersOverride property value to true
        // so we can override existing filters with registered
        // alias/name in addFilter method.
        $overrideStatus = $this->getOption('filters_override', false);
        if ($overrideStatus) {
            $this->setFiltersOverride(true);
        }

        // Get filters and bind it to field.
        $filters = $this->getOption('filters', []);
        foreach ($filters as $filter) {
            $this->addFilter($filter);
        }

        return $this;
    }
817066
protected function _configureBar()
    {
        $filters = array('following');

        if ($this->getController()->getRepository()->hasBehavior('administrable')) {
            $filters[] = 'administering';
        }

        $this->setActor($this->getController()->actor);

        foreach ($filters as $filter) {
            $label = array(
                strtoupper('COM-'.$this->getIdentifier()->package.'-NAV-FILTER-'.$filter),
                strtoupper('COM-ACTORS-NAV-FILTER-'.$filter),
            );

            $this->addNavigation('navbar-'.$filter, translate($label),
                    array(
                        'option' => $this->getController()->option,
                        'view' => $this->getController()->view,
                        'oid' => $this->getController()->actor->id, 'filter' => $filter,
                    ),
                    $this->getController()->filter == $filter);
        }

        $filter = pick($this->getController()->filter, 'following');

        $title = array(
            strtoupper('COM-'.$this->getIdentifier()->package.'-NAV-TITLE-'.$filter),
            strtoupper('COM-ACTORS-NAV-TITLE-'.$filter),
        );

        $this->setTitle(sprintf(translate($title), $this->getController()->actor->name));
    }
506570
protected function getFilterClassOptions()
    {
        // Create Options:
        
        $options = [];
        
        // Obtain Filter Subclasses:
        
        $filters = ClassInfo::subclassesFor(Filter::class);
        
        // Remove Abstract Superclass:
        
        array_shift($filters);
        
        // Define Options:
        
        foreach ($filters as $filter) {
            $options[$filter] = $filter::singleton()->getTitle();
        }
        
        // Sort Options, Ensuring Default Filter is First:
        
        uasort($options, function ($a, $b) {
            return ($a === DefaultFilter::singleton()->getTitle()) ? -1 : strcasecmp($a, $b);
        });
        
        // Answer Options:
        
        return $options;
    }
1024937
protected function loadFilter($filter)
	{
		static $misses = [];

		if ( ! in_array($filter, $misses))
		{
			try
			{
				if ($obj = \Dependency::resolve('security.filter.'.strtolower($filter), array($this)))
				{
					$this->filters[strtolower($filter)] = $obj;

					return true;
				}
			}
			catch (\Fuel\Dependency\ResolveException $e)
			{
				// we don't have a class for this filter
				$misses[] = $filter;
			}
		}

		return false;
	}
605983
public function getFilters()
    {
        $filters = isset($this->requestParams[self::PARAM_FILTERS]) ?
            $this->requestParams[self::PARAM_FILTERS] : self::DEFAULT_FILTERS;

        return $filters;
    }