DMS\Bundle\FilterBundle\Form\EventListener\DelegatingFilterListener::onPostSubmit PHP Метод

onPostSubmit() публичный Метод

POST_SUBMIT is fired for every level of the form, from fields to embedded forms. this method will filter any level that returns an entity, or will only filter the root entity if 'cascade_filter' is set to false.
public onPostSubmit ( Symfony\Component\Form\FormEvent $event )
$event Symfony\Component\Form\FormEvent
    public function onPostSubmit(FormEvent $event)
    {
        $form = $event->getForm();
        if (!$form->isRoot() && !$this->getRootFormCascadeOption($form)) {
            return;
        }
        $clientData = $form->getData();
        if (!is_object($clientData)) {
            return;
        }
        $this->filterService->filterEntity($clientData);
    }

Usage Example

 public function testFilterOnPostBind()
 {
     $entity = new AnnotatedClass();
     $form = $this->getMockForm();
     $form->expects($this->once())->method('isRoot')->will($this->returnValue(true));
     $form->expects($this->once())->method('getData')->will($this->returnValue($entity));
     $this->delegate->expects($this->once())->method('filterEntity');
     $this->listener->onPostSubmit(new FormEvent($form, null));
 }