Fetch Filter item by it's label.

@param FilterItem[] $filterItems All Filter items
@param string       $filterLabel Filter Label

@return bool|FilterItem
775956
protected function getFilterItemByLabel(array $filterItems, $filterLabel)
    {
        foreach ($filterItems as $item) {
            if ((string) $item->getValue() === (string) $filterLabel) {
                return $item;
            }
        }

        return false;
    }
716558
public function get($filterKey)
    {
        $filters = $this->session->get('filters', array());

        if (!array_key_exists ($filterKey, $filters)) {
            return null;
        }

        return $filters[$filterKey];
    }
1354661
protected function displayExtendedFilterValues($filteredBy) {
		
		$values = array();
		foreach ($filteredBy as $key => $value) {
			$values[] = '<span class="label label-info">' . $key . '</span> ' . $value;
		}
		return implode(', ', $values);
	}
112723
public function searchFilter($searchFilters, $options = [])
    {
        $_options = [];

        $options = array_merge($_options, $options);

        return ($searchFilters ? $this->Search->filterForm($searchFilters) : null);
    }
1052485
public function filter(array $filters)
	{
		foreach ($filters as $filter) {
			if ($filter->isValueSet()) {
				if ($filter->hasConditionCallback()) {
					Callback::invokeArgs(
						$filter->getConditionCallback(),
						[$this->data_source, $filter->getValue()]
					);
				} else {
					if ($filter instanceof Filter\FilterText) {
						$this->applyFilterText($filter);
					} elseif ($filter instanceof Filter\FilterMultiSelect) {
						$this->applyFilterMultiSelect($filter);
					} elseif ($filter instanceof Filter\FilterSelect) {
						$this->applyFilterSelect($filter);
					} elseif ($filter instanceof Filter\FilterDate) {
						$this->applyFilterDate($filter);
					} elseif ($filter instanceof Filter\FilterDateRange) {
						$this->applyFilterDateRange($filter);
					} elseif ($filter instanceof Filter\FilterRange) {
						$this->applyFilterRange($filter);
					}
				}
			}
		}

		return $this;
	}
917662
public function toArray($filterVariableContent = false, &$filtered = array()){

        $data = array();
        $data['serial'] = $this->getSerial();
        $tag = $this->getQtiTag();
        if(!empty($tag)){
            $data['qtiClass'] = $tag;
        }
        $attributes = $this->getAttributeValues();
        $data['attributes'] = empty($attributes) ? new StdClass() : $attributes;

        if($this instanceof FlowContainer){
            $data['body'] = $this->getBody()->toArray($filterVariableContent, $filtered);
        }

        if(DEBUG_MODE){
            //in debug mode, add debug data, such as the related item
            $data['debug'] = array('relatedItem' => is_null($this->getRelatedItem())?'':$this->getRelatedItem()->getSerial());
        }

        return $data;
    }
1095983
public function getFilterData($filterId = null) {
        if ($filterId !== null) {
            foreach ($this->filterData->filters->filter as $filter) {
                if ($filter->id == $filterId) {
                    return $filter;
                }
            }

            return null;
        } else {
            return $this->filterData;
        }
    }
892822
public function getFilters( $filters = null, $label = 'Filter', $action = '' ) {

		if ( Pod::$deprecated_notice ) {
			pods_deprecated( 'Pods::getFilters', '2.0', 'Pods::filters' );
		}

		$params = array(
			'fields' => $filters,
			'label'  => $label,
			'action' => $action,
		);

		if ( is_array( $filters ) ) {
			$params = array_merge( $params, $filters );
		}

		echo $this->obj->filters( $params );
	}
1017481
protected function get_filter_values($filtername) {
        $values = [];
        foreach ($this->filtersapplied as $filter) {
            if ($filter[0] == $filtername) {
                $values[] = $filter[1];
            }
        }
        return $values;
    }
952642
private static function fixFilterFieldPath(?Filter $filter): ? Filter
    {
        if (is_null($filter)) {
            return $filter;
        }

        $filterAsArray = $filter->toArray();
        $filterAsArray['field'] = Item::getPathByField($filterAsArray['field']);

        return Filter::createFromArray($filterAsArray);
    }
818323
def filter_service_by_bp_rule_label(label):
    
    def inner_filter(items):
        """Inner filter for service. Accept if label in service.labels"""
        service = items["service"]
        if service is None:
            return False
        return label in service.labels

    return inner_filter
1080021
public static function find(Filter ...$filters)
    {
        $modelClass = get_called_class();
        $collection = new RepositoryCollection($modelClass);
        $collection->filter(...$filters);
        return $collection;
    }
553033
public function filter(array $items, array $filters): array
    {
        if (empty($filters)) {
            // no filters means return all items
            return $items;
        }

        return array_filter($items, function ($item) use ($filters) {
            foreach ($filters as $filter) {
                $value = $this->extractValue($item, $filter->getField());
                if (!$this->valueMatchesFilter($value, $filter)) {
                    // all filters must pass so any failure means we
                    // can stop checking this item immediately.
                    return false;
                }
            }

            return true;
        });
    }
944011
public function findForSearchFilter(ProductFilter $filter, OrderCollection $orderCollection = null)
    {
        $qb = $this->getEntityManager()->createQueryBuilder()
            ->from('HarvestCloudCoreBundle:Product', 'p')
            ->select('p')
            ->addSelect('GEO(p.latitude = :latitude, p.longitude = :longitude) AS distance')
            ->setParameter('latitude', $filter->getLatitude())
            ->setParameter('longitude', $filter->getLongitude())
            ->orderBy('distance')
            ->setMaxResults(20)
        ;

        if ($filter->getRange())
        {
            $qb->where('GEO(p.latitude = :latitude, p.longitude = :longitude) <= :range');
            $qb->setParameter('range', $filter->getRange());
        }

        if ($filter->getCategory())
        {
            $qb->join('p.category', 'c');
            $qb->andWhere('c.lft >= :lft');
            $qb->andWhere('c.rgt <= :rgt');
            $qb->setParameter('lft', $filter->getCategory()->getLft());
            $qb->setParameter('rgt', $filter->getCategory()->getRgt());
        }

        $qb->andWhere('p.quantity_available > 0');

        $q = $qb->getQuery();

        $products =  $q->execute();


        if ($orderCollection)
        {
            // Set quantity in cart
            $lineItemQuantities = $orderCollection->getLineItemQuantitiesIndexedByProductId();

            foreach ($products as $product)
            {
                $id = $product[0]->getId();

                if (array_key_exists($id, $lineItemQuantities))
                {
                    $product[0]->setQuantityInCart($lineItemQuantities[$id]);
                }
            }
        }

        return $products;
    }
383239
public function fetch($class, array $filters = [], array $sortBy = null, $page = 0, $limit = -1, $count = false)
    {
        try {
            return $this->get($class)->find($filters, $sortBy, $page, $limit, $count);
        } catch (FinderException $e) {
            $data = $this->om->getRepository($class)->findBy($filters, null, 0 < $limit ? $limit : null, $page);

            return $count ? count($data) : $data;
        }
    }
1154897
public function labels($labels = null)
    {
        if ($labels === null)
        {
            return $this->_labels;
        }

        $this->_labels = $labels;
        return $this;
    }
35976
protected function filter($packageNames, $filters)
    {
        if (empty($filters)) {
            return $packageNames;
        }

        $packages = [];
        foreach ($packageNames as $packageName) {
            if (count($package = $this->repository->findPackages($packageName)) > 0) {
                foreach ($filters as $filter) {
                    $package = array_filter($package, $filter);
                }
                if ($package = current($package)) {
                    $packages[$packageName] = $package;
                }
            }
        }

        return array_map(
            function ($package) {
                /** @var PackageInterface $package */
                return $package->getName();
            },
            $packages
        );
    }