/** * @inheritDoc * @throws \UnexpectedValueException */ public function getFormOptions(FilterInterface $filter, QueryBuilder $qb, $alias) { if (count($filter->getAttributes()) > 1) { throw new \UnexpectedValueException("Autocomplete filters does not support multiple attributes ({$filter->getCode()})"); } /** @var FamilyInterface $currentFamily */ $currentFamily = $filter->getOptions()['family']; $attribute = $currentFamily->getAttribute(current($filter->getAttributes())); return ['family' => $attribute->getFormOptions()['family']]; }
/** * @param FilterInterface $filter * @param int $index * @return FilterConfigurationHandler * @throws UnexpectedValueException */ public function addFilter(FilterInterface $filter, $index = null) { if (null === $index) { $this->filters[$filter->getCode()] = $filter; } else { $count = count($this->filters); if (!is_int($index) && !is_numeric($index)) { throw new UnexpectedValueException("Given index should be an integer '{$index}' given"); } if (abs($index) > $count) { $index = 0; } if ($index < 0) { $index = $count + $index; } /** @noinspection AdditionOperationOnArraysInspection */ $this->filters = array_slice($this->filters, 0, $index, true) + [$filter->getCode() => $filter] + array_slice($this->filters, $index, $count - $index, true); } return $this; }