当前位置: 首页>>代码示例>>PHP>>正文


PHP Admin::validate方法代码示例

本文整理汇总了PHP中Sonata\AdminBundle\Admin\Admin::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP Admin::validate方法的具体用法?PHP Admin::validate怎么用?PHP Admin::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sonata\AdminBundle\Admin\Admin的用法示例。


在下文中一共展示了Admin::validate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: validate

 /**
  * @param ErrorElement $errorElement
  * @param mixed|\Application\Sonata\ClientBundle\Entity\Client $object
  */
 public function validate(ErrorElement $errorElement, $object)
 {
     /* @var $object \Application\Sonata\ClientBundle\Entity\Client */
     parent::validate($errorElement, $object);
     //EU validate NotBlank
     if (!$object->getNTVACEE() && $object->getPaysPostal() && $object->getPaysPostal()->getCode() && in_array($object->getPaysPostal()->getCode(), ListCountries::getCountryEUCode())) {
         $errorElement->with('N_TVA_CEE')->addViolation('This value should not be blank.')->end();
     }
     if (!$object->getNTVACEEFacture() && $object->getPaysFacturation() && $object->getPaysFacturation()->getCode() && in_array($object->getPaysFacturation()->getCode(), ListCountries::getCountryEUCode())) {
         $errorElement->with('N_TVA_CEE_facture')->addViolation('This value should not be blank.')->end();
     }
     /*  if ($object->getNTVACEEFacture() && !preg_match('/^FR \d{2} \d{3} \d{3} \d{3}$/', $object->getNTVACEEFacture())) {
         	$errorElement->with('N_TVA_CEE_facture')->addViolation('Le format du N° TVA CEE facturé est incorrect.   Respecter : FR XX XXX XXX XXX')->end();
         } */
     $this->validateNTVACEEFacture($errorElement, $object);
     if ($object->getAutreDestinataireDeFacturation()) {
         //validate NotBlank
         foreach (array('raison_sociale_2') as $field) {
             $method = 'get' . str_replace(' ', '', ucwords(str_replace('_', ' ', $field)));
             if (method_exists($object, $method) && !$object->{$method}()) {
                 $errorElement->with($field)->addViolation('This value should not be blank.')->end();
             }
         }
     }
     $value = $object->getSiret();
     if (!preg_match('/^\\d{3} \\d{3} \\d{3} \\d{3} \\d{2}$/', $value)) {
         $errorElement->with('siret')->addViolation('Le format du N° SIRET est incorrect.   Respecter : xxx xxx xxx xxx xx')->end();
     } else {
         $value = $object->getNTVAFR();
         $siret = substr($object->getSiret(), 0, 11);
         if ($value) {
             if (!preg_match('/^FR (\\d{2}|ZW) ' . $siret . '$/', $value)) {
                 $errorElement->with('N_TVA_FR')->addViolation('Non concordance entre le SIRET et le N° TVA FR.   Respecter FR xx (+SIREN xxx xxx xxx)')->end();
             }
         }
     }
     $value = $object->getNumDossierFiscal();
     if ($value) {
         if (!preg_match('/^\\d{6}\\/\\d{2}$/', $value)) {
             $errorElement->with('num_dossier_fiscal')->addViolation('"Num dossier fiscal" non valide, devrait avoir le format xxxxxx/xx')->end();
         }
     }
     $value = $object->getDateDeDepot();
     if ($value && $object->getNatureDuClient()) {
         if (in_array($object->getNatureDuClient()->getId(), array(ListNatureDuClients::DEB, ListNatureDuClients::DES)) && $value != 31) {
             $errorElement->with('date_de_depot_id')->addViolation('"Date de dépôt" non cohérente')->end();
         }
     }
     /**
              * If CENTRE DES IMPOTS = DRESG/6 and date <> 19 : No validation possible - Message on DATE : "CDI = DRESG, date = 19"
     
     If CENTRE DES IMPOTS = CDI-94/7 and date <> 15 or 24 : No validation possible - Message on DATE : "CDI = CDI-94, date = 15 or 24"
     
     If CENTRE DES IMPOTS = CISD/9 and date <> 31 : No validation possible - Message on DATE : "CDI = CISD, date = 31"
     */
     $centerDesImpotsID = $object->getCenterDesImpots() ? $object->getCenterDesImpots()->getId() : 0;
     $dateDepot = $object->getDateDeDepot();
     if ($centerDesImpotsID && $dateDepot) {
         if ($centerDesImpotsID == 6 && $dateDepot != 19) {
             $errorElement->with('date_de_depot_id')->addViolation('CDI = DRESG, date = 19')->end();
         }
         if ($centerDesImpotsID == 7 && ($dateDepot != 15 && $dateDepot != 24)) {
             $errorElement->with('date_de_depot_id')->addViolation('CDI = CDI-94, date = 15 or 24')->end();
         }
         if ($centerDesImpotsID == 9 && $dateDepot != 31) {
             $errorElement->with('date_de_depot_id')->addViolation('CDI = CISD, date = 31')->end();
         }
     }
 }
开发者ID:defan-marunchak,项目名称:eurotax,代码行数:73,代码来源:ClientAdmin.php

示例2: validate

 /**
  * @param ErrorElement $errorElement
  * @param mixed $object
  */
 public function validate(ErrorElement $errorElement, $object)
 {
     $this->_autofixeuroformat($object);
     /* @var $object \Application\Sonata\ClientOperationsBundle\Entity\AbstractBaseEntity */
     parent::validate($errorElement, $object);
     $value = $object->getDatePiece();
     if ($value) {
         $this->month = $value->format('m');
         $this->year = $value->format('Y');
         if ($this->getLocking() && $object instanceof AbstractBaseEntity) {
             if ($object->getStatus() && $object->getStatus()->getId() == 1) {
                 $errorElement->with('date_piece')->addViolation('Sorry with month is locked')->end();
             }
         }
     }
 }
开发者ID:defan-marunchak,项目名称:eurotax,代码行数:20,代码来源:AbstractTabsAdmin.php


注:本文中的Sonata\AdminBundle\Admin\Admin::validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。