當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。