protected function validate()
    {
        if (!$this->validator instanceof ValidatorInterface) {
            return;
        }

        $valid = true;
        if ($this->getEntityContainerMap()->count() > 0) {
            $entityContainers = $this->getEntityContainerMap()->getAll();

            $this->logger->debug('start form entity valiation', array('name' => $this->getName()));

            /**
             * @var $entityContainer    \Naucon\Form\Mapper\EntityContainerInterface
             */
            foreach ($entityContainers as $entityContainer) {
                if ($entityContainer->hasValidate()) {
                    $this->logger->debug('invoke form prevalidator hook', array('name' => $this->getName(), 'entity' => $entityContainer->getName()));
                    // prevalidation hook
                    $entityContainer->invokeHook('prevalidatorHook');

                    $violations = $this->validator->validate($entityContainer->getEntity(), null, $this->configuration->get('validation_groups'));
                    if (is_array($violations) && count($violations)) {
                        // TODO set FormValidations to $entityContainer
                        /**
                         * @var \Naucon\Form\Validator\ViolationInterface $violation
                         */
                        $violationsDump = array();
                        foreach ($violations as $violation) {
                            $violationsDump[$violation->getName()] = $violation->getMessage();
                            $entityContainer->setError($violation->getName(), new FormError($violation->getName(), $violation->getMessage()));
                        }
                        $valid = false;

                        $this->logger->debug('form entity violations', array('name' => $this->getName(), 'entity' => $entityContainer->getName(), 'violations' => $violationsDump));
                    }

                    // postvalidation hook
                    $this->logger->debug('invoke form postvalidator hook', array('name' => $this->getName(), 'entity' => $entityContainer->getName()));
                    $entityContainer->invokeHook('postvalidatorHook');

                    if ($entityContainer->hasErrors()) {
                        $valid = false;
                    }
                }
            }
        }

        if ($valid) {
            $this->logger->debug('finished form entity valiation successful', array('name' => $this->getName()));
        } else {
            $this->logger->debug('finished form entity valiation failed', array('name' => $this->getName()));
        }
        $this->setValid($valid);
    }
protected function validate()
    {
        if (!$this->validator instanceof ValidatorInterface) {
            return;
        }

        $valid = true;
        if ($this->getEntityContainerMap()->count() > 0) {
            $entityContainers = $this->getEntityContainerMap()->getAll();

            $this->logger->debug('start form entity valiation', array('name' => $this->getName()));

            /**
             * @var $entityContainer    \Naucon\Form\Mapper\EntityContainerInterface
             */
            foreach ($entityContainers as $entityContainer) {
                if ($entityContainer->hasValidate()) {
                    $this->logger->debug('invoke form prevalidator hook', array('name' => $this->getName(), 'entity' => $entityContainer->getName()));
                    // prevalidation hook
                    $entityContainer->invokeHook('prevalidatorHook');

                    $violations = $this->validator->validate($entityContainer->getEntity(), null, $this->configuration->get('validation_groups'));
                    if (is_array($violations) && count($violations)) {
                        // TODO set FormValidations to $entityContainer
                        /**
                         * @var \Naucon\Form\Validator\ViolationInterface $violation
                         */
                        $violationsDump = array();
                        foreach ($violations as $violation) {
                            $violationsDump[$violation->getName()] = $violation->getMessage();
                            $entityContainer->setError($violation->getName(), new FormError($violation->getName(), $violation->getMessage()));
                        }
                        $valid = false;

                        $this->logger->debug('form entity violations', array('name' => $this->getName(), 'entity' => $entityContainer->getName(), 'violations' => $violationsDump));
                    }

                    // postvalidation hook
                    $this->logger->debug('invoke form postvalidator hook', array('name' => $this->getName(), 'entity' => $entityContainer->getName()));
                    $entityContainer->invokeHook('postvalidatorHook');

                    if ($entityContainer->hasErrors()) {
                        $valid = false;
                    }
                }
            }
        }

        if ($valid) {
            $this->logger->debug('finished form entity valiation successful', array('name' => $this->getName()));
        } else {
            $this->logger->debug('finished form entity valiation failed', array('name' => $this->getName()));
        }
        $this->setValid($valid);
    }
protected function validate ( ) { if ( ! $ this -> validator instanceof ValidatorInterface ) { return ; } $ valid = true ; if ( $ this -> getEntityContainerMap ( ) -> count ( ) > 0 ) { $ entityContainers = $ this -> getEntityContainerMap ( ) -> getAll ( ) ; $ this -> logger -> debug ( 'start form entity valiation' , array ( 'name' => $ this -> getName ( ) ) ) ; /**
             * @var $entityContainer    \Naucon\Form\Mapper\EntityContainerInterface
             */ foreach ( $ entityContainers as $ entityContainer ) { if ( $ entityContainer -> hasValidate ( ) ) { $ this -> logger -> debug ( 'invoke form prevalidator hook' , array ( 'name' => $ this -> getName ( ) , 'entity' => $ entityContainer -> getName ( ) ) ) ; // prevalidation hook $ entityContainer -> invokeHook ( 'prevalidatorHook' ) ; $ violations = $ this -> validator -> validate ( $ entityContainer -> getEntity ( ) , null , $ this -> configuration -> get ( 'validation_groups' ) ) ; if ( is_array ( $ violations ) && count ( $ violations ) ) { // TODO set FormValidations to $entityContainer /**
                         * @var \Naucon\Form\Validator\ViolationInterface $violation
                         */ $ violationsDump = array ( ) ; foreach ( $ violations as $ violation ) { $ violationsDump [ $ violation -> getName ( ) ] = $ violation -> getMessage ( ) ; $ entityContainer -> setError ( $ violation -> getName ( ) , new FormError ( $ violation -> getName ( ) , $ violation -> getMessage ( ) ) ) ; } $ valid = false ; $ this -> logger -> debug ( 'form entity violations' , array ( 'name' => $ this -> getName ( ) , 'entity' => $ entityContainer -> getName ( ) , 'violations' => $ violationsDump ) ) ; } // postvalidation hook $ this -> logger -> debug ( 'invoke form postvalidator hook' , array ( 'name' => $ this -> getName ( ) , 'entity' => $ entityContainer -> getName ( ) ) ) ; $ entityContainer -> invokeHook ( 'postvalidatorHook' ) ; if ( $ entityContainer -> hasErrors ( ) ) { $ valid = false ; } } } } if ( $ valid ) { $ this -> logger -> debug ( 'finished form entity valiation successful' , array ( 'name' => $ this -> getName ( ) ) ) ; } else { $ this -> logger -> debug ( 'finished form entity valiation failed' , array ( 'name' => $ this -> getName ( ) ) ) ; } $ this -> setValid ( $ valid ) ; }
validate bind data

@access    protected
validate bind data