當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ExecutionContext::getPropertyPath方法代碼示例

本文整理匯總了PHP中Symfony\Component\Validator\ExecutionContext::getPropertyPath方法的典型用法代碼示例。如果您正苦於以下問題:PHP ExecutionContext::getPropertyPath方法的具體用法?PHP ExecutionContext::getPropertyPath怎麽用?PHP ExecutionContext::getPropertyPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\Validator\ExecutionContext的用法示例。


在下文中一共展示了ExecutionContext::getPropertyPath方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: isVoteValid

 /**
  * {@inheritdoc}
  */
 public function isVoteValid(ExecutionContext $context)
 {
     if (!$this->checkValue($this->value)) {
         $message = 'A vote cannot have a 0 value';
         $propertyPath = $context->getPropertyPath() . '.value';
         $context->addViolationAtPath($propertyPath, $message);
     }
 }
開發者ID:rampelli,項目名稱:FOSCommentBundle,代碼行數:11,代碼來源:Vote.php

示例2: isVoteValid

 /**
  * {@inheritdoc}
  */
 public function isVoteValid(ExecutionContext $context)
 {
     if (!$this->checkValue($this->value)) {
         $propertyPath = $context->getPropertyPath() . '.value';
         $context->setPropertyPath($propertyPath);
         $context->addViolation('A vote cannot have a 0 value', array(), null);
     }
 }
開發者ID:radzikowski,項目名稱:CraftyComponents,代碼行數:11,代碼來源:Vote.php

示例3: validateValueAsYaml

 public function validateValueAsYaml(ExecutionContext $context)
 {
     try {
         Inline::load($this->value);
     } catch (ParserException $e) {
         $context->setPropertyPath($context->getPropertyPath() . '.value');
         $context->addViolation('This value is not valid YAML syntax', array(), $this->value);
     }
 }
開發者ID:geoffreytran,項目名稱:zym,代碼行數:9,代碼來源:Parameter.php

示例4: isEmailValid

 public function isEmailValid(ExecutionContext $context)
 {
     // somehow you have an array of "fake email"
     $fakeEmails = array('test@test.com');
     // check if the name is actually a fake email
     if (in_array($this->getEmail(), $fakeEmails)) {
         $propertyPath = $context->getPropertyPath() . '.email';
         $context->setPropertyPath($propertyPath);
         $context->addViolation('Tu ne te moquerais pas un peu de moi avec cet email ?', array(), null);
     }
 }
開發者ID:rvalois,項目名稱:Tutorial-Symfony2-SdZ,代碼行數:11,代碼來源:Contact.php

示例5: validateFormChildren

 public static function validateFormChildren(FormInterface $form, ExecutionContext $context)
 {
     if ($form->getAttribute('cascade_validation')) {
         $propertyPath = $context->getPropertyPath();
         $graphWalker = $context->getGraphWalker();
         // Adjust the property path accordingly
         if (!empty($propertyPath)) {
             $propertyPath .= '.';
         }
         $propertyPath .= 'children';
         $graphWalker->walkReference($form->getChildren(), Constraint::DEFAULT_GROUP, $propertyPath, true);
     }
 }
開發者ID:rouffj,項目名稱:symfony,代碼行數:13,代碼來源:DelegatingValidationListener.php

示例6: areImagesValid

 public function areImagesValid(ExecutionContext $context)
 {
     $captured_ids = array_map(function ($image) {
         return $image->getId();
     }, $this->images->toArray());
     $property_path = $context->getPropertyPath() . '.images';
     if (!count($captured_ids)) {
         $context->addViolationAt($property_path, 'Please select at least one image!', array(), null);
         return;
     }
     $count = $this->query_builder->andWhere($this->query_builder->expr()->in('i.id', $captured_ids))->select('COUNT(i.id)')->getQuery()->getSingleScalarResult();
     if (!$count) {
         $context->addViolation('Please select images from the list!', array(), null);
     }
 }
開發者ID:rodgermd,項目名稱:mura-show.com,代碼行數:15,代碼來源:BulkImages.php

示例7: validateFormData

 /**
  * Validates the data of a form
  *
  * This method is called automatically during the validation process.
  *
  * @param FormInterface    $form    The validated form
  * @param ExecutionContext $context The current validation context
  */
 public static function validateFormData(FormInterface $form, ExecutionContext $context)
 {
     if (is_object($form->getData()) || is_array($form->getData())) {
         $propertyPath = $context->getPropertyPath();
         $graphWalker = $context->getGraphWalker();
         // The Execute constraint is called on class level, so we need to
         // set the property manually
         $context->setCurrentProperty('data');
         // Adjust the property path accordingly
         if (!empty($propertyPath)) {
             $propertyPath .= '.';
         }
         $propertyPath .= 'data';
         foreach (self::getFormValidationGroups($form) as $group) {
             $graphWalker->walkReference($form->getData(), $group, $propertyPath, true);
         }
     }
 }
開發者ID:rfc1483,項目名稱:blog,代碼行數:26,代碼來源:DelegatingValidator.php

示例8: isEntityValid

 public function isEntityValid(ExecutionContext $context)
 {
     $propertyPath = $context->getPropertyPath() . '.fieldName';
     if ($this->getFieldType() == 'entity') {
         if ($this->getFragment() == null || $this->getBundleName() == null || $this->getEntityName() == null || $this->getRelationType() == null || $this->getPropertyName() == null) {
             $context->setPropertyPath($propertyPath);
             $context->addViolation('Incomplete relation value for ' . $this->getFieldName(), array(), null);
         }
     }
 }
開發者ID:r4cker,項目名稱:lowbi,代碼行數:10,代碼來源:Field.php

示例9: validateData

 /**
  * Validates the data of this form
  *
  * This method is called automatically during the validation process.
  *
  * @param ExecutionContext $context  The current validation context
  */
 public function validateData(ExecutionContext $context)
 {
     if (is_object($this->getData()) || is_array($this->getData())) {
         $groups = $this->getValidationGroups();
         $propertyPath = $context->getPropertyPath();
         $graphWalker = $context->getGraphWalker();
         if (null === $groups) {
             $groups = array(null);
         }
         // The Execute constraint is called on class level, so we need to
         // set the property manually
         $context->setCurrentProperty('data');
         // Adjust the property path accordingly
         if (!empty($propertyPath)) {
             $propertyPath .= '.';
         }
         $propertyPath .= 'data';
         foreach ($groups as $group) {
             $graphWalker->walkReference($this->getData(), $group, $propertyPath, true);
         }
     }
 }
開發者ID:noelg,項目名稱:symfony-demo,代碼行數:29,代碼來源:Form.php

示例10: esFechaPeriodoPruebaValida

 public function esFechaPeriodoPruebaValida(ExecutionContext $context)
 {
     $propertyPath = $context->getPropertyPath() . '.fechaInicioPrueba';
     if ($this->getPeriodoPrueba() == 1) {
         if ($this->getFechaInicioPrueba() > $this->getFechaTerminoPrueba()) {
             $context->setPropertyPath($propertyPath);
             $context->addViolation('compare dates test invalid', array(), null);
         }
     }
 }
開發者ID:rodrigomiranda,項目名稱:masleads,代碼行數:10,代碼來源:Campanas.php

示例11: isValid

 /**
  * Custom validation constraint
  * Not valid if no one recipient specified
  *
  * @param ExecutionContext $context
  */
 public function isValid(ExecutionContext $context)
 {
     $notValid = $this->getGroups()->isEmpty() && $this->getUsers()->isEmpty() && $this->getEmail() == null && $this->getOwner() == null;
     if ($notValid) {
         $propertyPath = $context->getPropertyPath() . '.recipientList';
         $context->addViolationAt($propertyPath, 'oro.notification.validators.recipient_list.empty.message');
     }
 }
開發者ID:ashutosh-srijan,項目名稱:findit_akeneo,代碼行數:14,代碼來源:RecipientList.php

示例12: isPackageUnique

 public function isPackageUnique(ExecutionContext $context)
 {
     try {
         if ($this->entityRepository->findOneByName($this->name)) {
             $propertyPath = $context->getPropertyPath() . '.repository';
             $context->setPropertyPath($propertyPath);
             $context->addViolation('A package with the name ' . $this->name . ' already exists.', array(), null);
         }
     } catch (\Doctrine\ORM\NoResultException $e) {
     }
 }
開發者ID:nesQuick,項目名稱:packagist,代碼行數:11,代碼來源:Package.php

示例13: esRutValido

 public function esRutValido(ExecutionContext $context)
 {
     $propertyPath = $context->getPropertyPath() . '.rut';
     $rut = $this->getRut();
     /* validando rut */
     $r = strtoupper(str_replace(array(".", "-"), "", $rut));
     $sub_rut = substr($r, 0, strlen($r) - 1);
     $sub_dv = substr($r, -1);
     $x = 2;
     $s = 0;
     for ($i = strlen($sub_rut) - 1; $i >= 0; $i--) {
         if ($x > 7) {
             $x = 2;
         }
         $s += $sub_rut[$i] * $x;
         $x++;
     }
     $dv = 11 - $s % 11;
     if ($dv == 10) {
         $dv = 'K';
     }
     if ($dv == 11) {
         $dv = '0';
     }
     if ($dv != $sub_dv) {
         $context->setPropertyPath($propertyPath);
         $context->addViolation('rut invalid', array(), null);
     }
 }
開發者ID:rodrigomiranda,項目名稱:upv-form-inscripcion,代碼行數:29,代碼來源:Inscripcion.php

示例14: testGetPropertyPathWithEmptyCurrentPropertyPath

 public function testGetPropertyPathWithEmptyCurrentPropertyPath()
 {
     $this->context = new ExecutionContext($this->globalContext, $this->translator, self::TRANS_DOMAIN, $this->metadata, 'currentValue', 'Group', '');
     $this->assertEquals('bam.baz', $this->context->getPropertyPath('bam.baz'));
 }
開發者ID:shomimn,項目名稱:builder,代碼行數:5,代碼來源:LegacyExecutionContextTest.php

示例15: isRegionValid

 public function isRegionValid(ExecutionContext $context)
 {
     if ($this->getCountry() && $this->getCountry()->hasRegions() && !$this->state) {
         $propertyPath = $context->getPropertyPath() . '.state';
         $context->addViolationAt($propertyPath, 'State is required for country %country%', array('%country%' => $this->getCountry()->getName()));
     }
 }
開發者ID:ashutosh-srijan,項目名稱:findit_akeneo,代碼行數:7,代碼來源:AbstractAddress.php


注:本文中的Symfony\Component\Validator\ExecutionContext::getPropertyPath方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。