本文整理汇总了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();
}
}
}
示例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();
}
}
}
}