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


PHP ExecutionContext::setPropertyPath方法代码示例

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


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

示例1: 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

示例2: validateOne

 public function validateOne(ExecutionContext $context)
 {
     $context->setCurrentClass('Foo');
     $context->setCurrentProperty('bar');
     $context->setGroup('mygroup');
     $context->setPropertyPath('foo.bar');
     $context->addViolation('My message', array('parameter'), 'invalidValue');
 }
开发者ID:NicolasBadey,项目名称:symfony,代码行数:8,代码来源:CallbackValidatorTest.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: testValidateDataAppendsPropertyPath

 public function testValidateDataAppendsPropertyPath()
 {
     $graphWalker = $this->createMockGraphWalker();
     $metadataFactory = $this->createMockMetadataFactory();
     $context = new ExecutionContext('Root', $graphWalker, $metadataFactory);
     $context->setPropertyPath('path');
     $object = $this->getMock('\\stdClass');
     $form = new Form('author');
     $graphWalker->expects($this->once())->method('walkReference')->with($object, null, 'path.data', true);
     $form->setData($object);
     $form->validateData($context);
 }
开发者ID:nickaggarwal,项目名称:sample-symfony2,代码行数:12,代码来源:FormTest.php

示例6: pickedOrderItems

 /**
  * @param  ExecutionContext $context
  * @return void
  * @deprecated
  */
 public function pickedOrderItems(ExecutionContext $context)
 {
     $count = 0;
     foreach ($this->items as $item) {
         $count += $item->getCount();
     }
     if ($count === 0) {
         /*
         $property_path = $context->getPropertyPath() . '.customer.phone';
         $property_path = $context->getPropertyPath() . '.items[0].count';
         $property_path = $context->getPropertyPath() . '.items.[0].count';
         $property_path = $context->getPropertyPath() . '.items.0.count';
         */
         $property_path = $context->getPropertyPath() . '.items[0].count';
         $context->setPropertyPath($property_path);
         $context->addViolation('You have to pick at least one pizza...', array(), null);
     }
 }
开发者ID:kadala,项目名称:AcmePizzaBundle,代码行数:23,代码来源:OrderFactory.php

示例7: esDniValido

 /**
  * Validador propio que comprueba si el DNI introducido es válido
  */
 public function esDniValido(ExecutionContext $context)
 {
     $nombre_propiedad = $context->getPropertyPath() . '.dni';
     $dni = $this->getDni();
     // Comprobar que el formato sea correcto
     if (0 === preg_match("/\\d{1,8}[a-z]/i", $dni)) {
         $context->setPropertyPath($nombre_propiedad);
         $context->addViolation('El DNI introducido no tiene el formato correcto (entre 1 y 8 números seguidos de una letra, sin guiones y sin dejar ningún espacio en blanco)', array(), null);
         return;
     }
     // Comprobar que la letra cumple con el algoritmo
     $numero = substr($dni, 0, -1);
     $letra = strtoupper(substr($dni, -1));
     if ($letra != substr("TRWAGMYFPDXBNJZSQVHLCKE", strtr($numero, "XYZ", "012") % 23, 1)) {
         $context->setPropertyPath($nombre_propiedad);
         $context->addViolation('La letra no coincide con el número del DNI. Comprueba que has escrito bien tanto el número como la letra', array(), null);
     }
 }
开发者ID:neozoe,项目名称:Cupon,代码行数:21,代码来源:Usuario.php

示例8: testValidateFormDataAppendsPropertyPath

 public function testValidateFormDataAppendsPropertyPath()
 {
     $graphWalker = $this->getMockGraphWalker();
     $metadataFactory = $this->getMockMetadataFactory();
     $context = new ExecutionContext('Root', $graphWalker, $metadataFactory);
     $context->setPropertyPath('path');
     $object = $this->getMock('\\stdClass');
     $form = $this->getForm();
     $graphWalker->expects($this->once())->method('walkReference')->with($object, 'Default', 'path.data', true);
     $form->setData($object);
     DelegatingValidator::validateFormData($form, $context);
 }
开发者ID:NicolasBadey,项目名称:symfony,代码行数:12,代码来源:DelegatingValidatorTest.php

示例9: 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

示例10: endBeforeStart

 /**
  *
  * @param ExecutionContext $context 
  */
 public function endBeforeStart(ExecutionContext $context)
 {
     if ($this->getEnd()) {
         if ($this->getEnd() <= $this->getStart()) {
             $propertyPath = $context->getPropertyPath() . '.end';
             $context->setPropertyPath($propertyPath);
             $context->addViolation('The end of release could not be before start!', array(), null);
         }
     }
 }
开发者ID:neblion,项目名称:scrum,代码行数:14,代码来源:ProjectRelease.php

示例11: linkValide

 public function linkValide(ExecutionContext $context)
 {
     $valider = new ValidationLink();
     $valider->setLink($this->getLink());
     $valider->checkLink();
     if ($valider->getResponse() == false) {
         $propertyPath = $context->getPropertyPath() . '.Link';
         $context->setPropertyPath($propertyPath);
         $context->addViolation('Lien invalide : veuillez vérifier si votre lien est gérer par le site.', array(), null);
     }
 }
开发者ID:artz20,项目名称:Tv-shows-zone,代码行数:11,代码来源:Episode.php

示例12: testValidateFormChildrenAppendsPropertyPath

 public function testValidateFormChildrenAppendsPropertyPath()
 {
     $graphWalker = $this->getMockGraphWalker();
     $metadataFactory = $this->getMockMetadataFactory();
     $context = new ExecutionContext('Root', $graphWalker, $metadataFactory);
     $context->setPropertyPath('path');
     $form = $this->getBuilder()->setAttribute('cascade_validation', true)->getForm();
     $form->add($this->getForm('firstName'));
     $graphWalker->expects($this->once())->method('walkReference')->with($form->getChildren(), 'Default', 'path.children', true);
     DelegatingValidator::validateFormChildren($form, $context);
 }
开发者ID:neokensou,项目名称:symfony,代码行数:11,代码来源:DelegatingValidatorTest.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: 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

示例15: 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


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