当前位置: 首页>>代码示例>>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;未经允许,请勿转载。