Filter/FilterBuilderUpdater.php
protected function getFilterCondition(FormInterface $form, AbstractType $formType, QueryInterface $filterQuery, $alias)
    {
        $values = $this->prepareFilterValues($form, $formType);
        $values += array('alias' => $alias);
        $field = trim($values['alias'] . '.' . $form->getName(), '. ');

        $condition = null;

        // build a complete form name including parents
        $completeName = $form->getName();
        $parentForm = $form;
        do {
            $parentForm = $parentForm->getParent();
            if (!is_numeric($parentForm->getName()) && $parentForm->getConfig()->getMapped()) { // skip collection numeric index and not mapped fields
                $completeName = $parentForm->getName() . '.' . $completeName;
            }
        } while (!$parentForm->isRoot());

        // apply the filter by using the closure set with the 'apply_filter' option
        $callable = $form->getConfig()->getAttribute('apply_filter');

        if (false === $callable) {
            return null;
        }

        if ($callable instanceof \Closure) {
            $condition = $callable($filterQuery, $field, $values);
        } elseif (is_callable($callable)) {
            $condition = call_user_func($callable, $filterQuery, $field, $values);
        } else {
            // trigger a specific or a global event name
            $eventName = sprintf('lexik_form_filter.apply.%s.%s', $filterQuery->getEventPartName(), $completeName);
            if (!$this->dispatcher->hasListeners($eventName)) {
                $eventName = sprintf('lexik_form_filter.apply.%s.%s', $filterQuery->getEventPartName(), is_string($callable) ? $callable : $formType->getBlockPrefix());
            }

            $event = new GetFilterConditionEvent($filterQuery, $field, $values);
            $this->dispatcher->dispatch($eventName, $event);

            $condition = $event->getCondition();
        }

        // set condition path
        if ($condition instanceof ConditionInterface) {
            $condition->setName(
                trim(substr($completeName, strpos($completeName, '.')), '.') // remove first level
            );
        }

        return $condition;
    }
protected function getFilterCondition(FormInterface $form, AbstractType $formType, QueryInterface $filterQuery, $alias)
    {
        $values = $this->prepareFilterValues($form, $formType);
        $values += array('alias' => $alias);
        $field = trim($values['alias'] . '.' . $form->getName(), '. ');

        $condition = null;

        // build a complete form name including parents
        $completeName = $form->getName();
        $parentForm = $form;
        do {
            $parentForm = $parentForm->getParent();
            if (!is_numeric($parentForm->getName()) && $parentForm->getConfig()->getMapped()) { // skip collection numeric index and not mapped fields
                $completeName = $parentForm->getName() . '.' . $completeName;
            }
        } while (!$parentForm->isRoot());

        // apply the filter by using the closure set with the 'apply_filter' option
        $callable = $form->getConfig()->getAttribute('apply_filter');

        if (false === $callable) {
            return null;
        }

        if ($callable instanceof \Closure) {
            $condition = $callable($filterQuery, $field, $values);
        } elseif (is_callable($callable)) {
            $condition = call_user_func($callable, $filterQuery, $field, $values);
        } else {
            // trigger a specific or a global event name
            $eventName = sprintf('lexik_form_filter.apply.%s.%s', $filterQuery->getEventPartName(), $completeName);
            if (!$this->dispatcher->hasListeners($eventName)) {
                $eventName = sprintf('lexik_form_filter.apply.%s.%s', $filterQuery->getEventPartName(), is_string($callable) ? $callable : $formType->getBlockPrefix());
            }

            $event = new GetFilterConditionEvent($filterQuery, $field, $values);
            $this->dispatcher->dispatch($eventName, $event);

            $condition = $event->getCondition();
        }

        // set condition path
        if ($condition instanceof ConditionInterface) {
            $condition->setName(
                trim(substr($completeName, strpos($completeName, '.')), '.') // remove first level
            );
        }

        return $condition;
    }
protected function getFilterCondition ( FormInterface $ form , AbstractType $ formType , QueryInterface $ filterQuery , $ alias ) { $ values = $ this -> prepareFilterValues ( $ form , $ formType ) ; $ values += array ( 'alias' => $ alias ) ; $ field = trim ( $ values [ 'alias' ] . '.' . $ form -> getName ( ) , '. ' ) ; $ condition = null ; // build a complete form name including parents $ completeName = $ form -> getName ( ) ; $ parentForm = $ form ; do { $ parentForm = $ parentForm -> getParent ( ) ; if ( ! is_numeric ( $ parentForm -> getName ( ) ) && $ parentForm -> getConfig ( ) -> getMapped ( ) ) { // skip collection numeric index and not mapped fields $ completeName = $ parentForm -> getName ( ) . '.' . $ completeName ; } } while ( ! $ parentForm -> isRoot ( ) ) ; // apply the filter by using the closure set with the 'apply_filter' option $ callable = $ form -> getConfig ( ) -> getAttribute ( 'apply_filter' ) ; if ( false === $ callable ) { return null ; } if ( $ callable instanceof \ Closure ) { $ condition = $ callable ( $ filterQuery , $ field , $ values ) ; } elseif ( is_callable ( $ callable ) ) { $ condition = call_user_func ( $ callable , $ filterQuery , $ field , $ values ) ; } else { // trigger a specific or a global event name $ eventName = sprintf ( 'lexik_form_filter.apply.%s.%s' , $ filterQuery -> getEventPartName ( ) , $ completeName ) ; if ( ! $ this -> dispatcher -> hasListeners ( $ eventName ) ) { $ eventName = sprintf ( 'lexik_form_filter.apply.%s.%s' , $ filterQuery -> getEventPartName ( ) , is_string ( $ callable ) ? $ callable : $ formType -> getBlockPrefix ( ) ) ; } $ event = new GetFilterConditionEvent ( $ filterQuery , $ field , $ values ) ; $ this -> dispatcher -> dispatch ( $ eventName , $ event ) ; $ condition = $ event -> getCondition ( ) ; } // set condition path if ( $ condition instanceof ConditionInterface ) { $ condition -> setName ( trim ( substr ( $ completeName , strpos ( $ completeName , '.' ) ) , '.' ) // remove first level ) ; } return $ condition ; }
Get the condition through event dispatcher.

@param FormInterface  $form
@param AbstractType   $formType
@param QueryInterface $filterQuery
@param string         $alias
@return ConditionInterface|null
Get the condition through event dispatcher .