Esempio n. 1
0
 public function validateNomenclature2()
 {
     $nomenclature = $this->_object->getNomenclature();
     if ($nomenclature) {
         $lenNomen = strlen($nomenclature);
         if ($lenNomen < 8 || $lenNomen > 9) {
             $this->_errorElement->with('nomenclature')->addViolation('Code incorrect')->end();
         } else {
             /* @var $doctrine \Doctrine\Bundle\DoctrineBundle\Registry */
             $doctrine = \AppKernel::getStaticContainer()->get('doctrine');
             /* @var $em \Doctrine\ORM\EntityManager */
             $em = $doctrine->getManager();
             $nomenclatures = $em->getRepository('ApplicationSonataClientBundle:Nomenclature')->findBy(array('code' => ltrim($nomenclature, 0)));
             if (count($nomenclatures) == 0) {
                 $this->_errorElement->with('nomenclature')->addViolation('Code non trouvé')->end();
             }
         }
     }
     return $this;
 }