getPropertyPath() public method

public getPropertyPath ( )
示例#1
0
 /**
  * {@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);
     }
 }
示例#2
0
 /**
  * {@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);
     }
 }
示例#3
0
 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);
     }
 }
示例#4
0
 public function isEmailValid(ExecutionContext $context)
 {
     // somehow you have an array of "fake email"
     $fakeEmails = array('*****@*****.**');
     // 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);
     }
 }
 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);
     }
 }
示例#6
0
 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);
     }
 }
示例#7
0
 /**
  * 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);
         }
     }
 }
示例#8
0
文件: Field.php 项目: r4cker/lowbi
 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);
         }
     }
 }
示例#9
0
 /**
  * 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);
         }
     }
 }
示例#10
0
 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);
         }
     }
 }
 /**
  * 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');
     }
 }
示例#12
0
 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) {
     }
 }
 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);
     }
 }
 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'));
 }
 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()));
     }
 }
示例#16
0
 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);
     }
 }
示例#17
0
 /**
  *
  * @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);
         }
     }
 }
示例#18
0
 /**
  * @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);
     }
 }
示例#19
0
 /**
  * @param ExecutionContext $ec
  */
 public function validateCreation(ExecutionContext $ec)
 {
     if (null === $this->getHandle()) {
         $ec->getGraphWalker()->walkReference($this, 'create', $ec->getPropertyPath(), true);
     }
 }
示例#20
0
 public static function validateFormChildren(FormInterface $form, ExecutionContext $context)
 {
     if ($form->getAttribute('cascade_validation')) {
         $propertyPath = $context->getPropertyPath();
         $graphWalker = $context->getGraphWalker();
         // The Execute constraint is called on class level, so we need to
         // set the property manually
         $context->setCurrentProperty('children');
         // Adjust the property path accordingly
         if (!empty($propertyPath)) {
             $propertyPath .= '.';
         }
         $propertyPath .= 'children';
         foreach (self::getFormValidationGroups($form) as $group) {
             $graphWalker->walkReference($form->getChildren(), $group, $propertyPath, true);
         }
     }
 }
示例#21
0
文件: Usuario.php 项目: neozoe/Cupon
 /**
  * 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);
     }
 }
示例#22
0
 public function isRegionValid(ExecutionContext $context)
 {
     if ($this->getCountry() && $this->getCountry()->hasRegions() && !$this->region && !$this->regionText) {
         // do not allow saving text region in case when region was checked from list
         // except when in base data region text existed
         // another way region_text field will be null, logic are placed in form listener
         $propertyPath = $context->getPropertyPath() . '.region';
         $context->addViolationAt($propertyPath, 'Region is required for country %country%', array('%country%' => $this->getCountry()->getName()));
     }
 }
示例#23
0
文件: Call.php 项目: dairdr/crm
 public function isPhoneValid(ExecutionContext $context)
 {
     if (!$this->getPhoneNumber() && !$this->getContactPhoneNumber()) {
         $propertyPath = $context->getPropertyPath() . '.contactPhoneNumber';
         $context->addViolationAt($propertyPath, 'orocrm.call.phone.required.message');
     }
 }