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


PHP Constraint::validatedBy方法代码示例

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


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

示例1: getInstance

 /**
  * Returns the validator for the supplied constraint.
  *
  * @param Constraint $constraint A constraint
  *
  * @return ConstraintValidatorInterface A validator for the supplied constraint
  *
  * @throws UnexpectedTypeException When the validator is not an instance of ConstraintValidatorInterface
  */
 public function getInstance(Constraint $constraint)
 {
     $name = $constraint->validatedBy();
     if (!isset($this->validators[$name])) {
         switch (get_class($constraint)) {
             case self::BASE_NAMESPACE . '\\All':
                 $name = self::BASE_NAMESPACE . '\\LegacyAllValidator';
                 break;
             case self::BASE_NAMESPACE . '\\Choice':
                 $name = self::BASE_NAMESPACE . '\\LegacyChoiceValidator';
                 break;
             case self::BASE_NAMESPACE . '\\Collection':
                 $name = self::BASE_NAMESPACE . '\\LegacyCollectionValidator';
                 break;
             case self::BASE_NAMESPACE . '\\Count':
                 $name = self::BASE_NAMESPACE . '\\LegacyCountValidator';
                 break;
             case self::BASE_NAMESPACE . '\\Length':
                 $name = self::BASE_NAMESPACE . '\\LegacyLengthValidator';
                 break;
             case self::FORM_BASE_NAMESPACE . '\\Form':
                 $name = self::FORM_BASE_NAMESPACE . '\\LegacyFormValidator';
                 break;
         }
         $this->validators[$name] = new $name();
     } elseif (is_string($this->validators[$name])) {
         $this->validators[$name] = $this->container->get($this->validators[$name]);
     }
     if (!$this->validators[$name] instanceof ConstraintValidatorInterface) {
         throw new UnexpectedTypeException($this->validators[$name], 'Symfony\\Component\\Validator\\ConstraintValidatorInterface');
     }
     return $this->validators[$name];
 }
开发者ID:raphael-thibierge,项目名称:ProgWebServerProject,代码行数:42,代码来源:LegacyConstraintValidatorFactory.php

示例2: getInstance

 /**
  * {@inheritDoc}
  */
 public function getInstance(Constraint $constraint)
 {
     $className = $constraint->validatedBy();
     if (!isset($this->validators[$className]) || $className === 'Symfony\\Component\\Validator\\Constraints\\CollectionValidator') {
         $this->validators[$className] = new $className();
     }
     return $this->validators[$className];
 }
开发者ID:senthil-r-wiredelta,项目名称:meilleure-visite,代码行数:11,代码来源:ConstraintValidatorFactory.php

示例3: getInstance

 /**
  * {@inheritdoc}
  */
 public function getInstance(Constraint $constraint)
 {
     $name = $constraint->validatedBy();
     if (isset($this->serviceNames[$name])) {
         return $this->container[$this->serviceNames[$name]];
     }
     return parent::getInstance($constraint);
 }
开发者ID:speedwork,项目名称:provider,代码行数:11,代码来源:ConstraintValidatorFactory.php

示例4: getInstance

 /**
  * @param Constraint $constraint
  * @return \Symfony\Component\Validator\ConstraintValidatorInterface
  */
 public function getInstance(Constraint $constraint)
 {
     $class_name = $constraint->validatedBy();
     if (!isset($this->validators[$class_name])) {
         $this->validators[$class_name] = new $class_name();
     }
     return $this->validators[$class_name];
 }
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:12,代码来源:ConstraintValidatorFactory.php

示例5: getInstance

 /**
  * {@inheritdoc}
  */
 public function getInstance(Constraint $constraint)
 {
     $className = $constraint->validatedBy();
     if (!isset($this->validators[$className])) {
         $this->validators[$className] = 'validator.expression' === $className ? new ExpressionValidator($this->propertyAccessor) : new $className();
     }
     return $this->validators[$className];
 }
开发者ID:rolas123,项目名称:weather-homework,代码行数:11,代码来源:ConstraintValidatorFactory.php

示例6: getInstance

 /**
  * {@inheritdoc}
  */
 public function getInstance(Constraint $constraint)
 {
     $class_name = $constraint->validatedBy();
     if (!isset($this->validators[$class_name])) {
         $this->validators[$class_name] = $this->classResolver->getInstanceFromDefinition($class_name);
     }
     return $this->validators[$class_name];
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:11,代码来源:ConstraintValidatorFactory.php

示例7: getInstance

 /**
  * Returns the validator for the supplied constraint.
  *
  * @param  Constraint          $constraint A constraint
  * @return ConstraintValidator A validator for the supplied constraint
  */
 public function getInstance(Constraint $constraint)
 {
     $name = $constraint->validatedBy();
     if (isset($this->validators[$name])) {
         return $this->validators[$name];
     }
     $this->validators[$name] = $this->createValidator($name);
     return $this->validators[$name];
 }
开发者ID:hafedhbou,项目名称:hetic-p2017,代码行数:15,代码来源:ConstraintValidatorFactory.php

示例8: getInstance

 /**
  * Returns the validator for the supplied constraint.
  *
  * @param Constraint $constraint A constraint
  *
  * @return Symfony\Component\Validator\ConstraintValidator A validator for the supplied constraint
  */
 public function getInstance(Constraint $constraint)
 {
     $className = $constraint->validatedBy();
     if (!isset($this->validators[$className])) {
         $this->validators[$className] = new $className();
     } elseif (is_string($this->validators[$className])) {
         $this->validators[$className] = $this->container[$this->validators[$className]];
     }
     return $this->validators[$className];
 }
开发者ID:mparaiso,项目名称:doctrineodmserviceprovider,代码行数:17,代码来源:PimpleConstraintValidatorFactory.php

示例9: getInstance

 /**
  * {@inheritDoc}
  */
 public function getInstance(Constraint $constraint)
 {
     $name = $constraint->validatedBy();
     if (!isset($this->validators[$name])) {
         $this->validators[$name] = new $name();
     } elseif (is_string($this->validators[$name])) {
         $this->validators[$name] = $this->serviceLocator->getService($this->validators[$name]);
     }
     return $this->validators[$name];
 }
开发者ID:kdyby,项目名称:validator,代码行数:13,代码来源:ConstraintValidatorFactory.php

示例10: getInstance

 public function getInstance(Constraint $constraint)
 {
     $className = $constraint->validatedBy();
     if (!isset($this->validators[$className])) {
         if (class_exists($className)) {
             $this->validators[$className] = new $className();
         } else {
             $this->validators[$className] = $this->app[$className];
         }
     }
     return $this->validators[$className];
 }
开发者ID:elfet,项目名称:silicone,代码行数:12,代码来源:ConstraintValidatorFactory.php

示例11: getInstance

 /**
  * Returns the validator for the supplied constraint.
  *
  * @param Constraint $constraint A constraint
  *       
  * @return ConstraintValidatorInterface A validator for the supplied constraint
  *        
  * @throws UnexpectedTypeException When the validator is not an instance of ConstraintValidatorInterface
  */
 public function getInstance(Constraint $constraint)
 {
     $name = $constraint->validatedBy();
     if (!isset($this->validators[$name])) {
         $this->validators[$name] = new $name();
     } elseif (is_string($this->validators[$name])) {
         $this->validators[$name] = $this->container->get($this->validators[$name]);
     }
     if (!$this->validators[$name] instanceof ConstraintValidatorInterface) {
         throw new UnexpectedTypeException($this->validators[$name], 'Symfony\\Component\\Validator\\ConstraintValidatorInterface');
     }
     return $this->validators[$name];
 }
开发者ID:skelpo,项目名称:framework,代码行数:22,代码来源:ConstraintValidatorFactory.php

示例12: getInstance

 /**
  * Returns a contraint validator from the container service, setting it if it
  * doesn't exist yet
  *
  * Throws an exception if validator service is not instance of
  * ConstraintValidatorInterface.
  *
  * @param  Constraint $constraint
  * @return ConstraintValidatorInterface
  * @throws \LogicException
  */
 public function getInstance(Constraint $constraint)
 {
     $className = $constraint->validatedBy();
     $id = $this->getServiceIdFromClass($className);
     if (!$this->container->has($id)) {
         $this->container->set($id, new $className());
     }
     $validator = $this->container->get($id);
     if (!$validator instanceof ConstraintValidatorInterface) {
         throw new \LogicException('Service "' . $id . '" is not instance of ConstraintValidatorInterface');
     }
     return $validator;
 }
开发者ID:skoop,项目名称:symfony-sandbox,代码行数:24,代码来源:DependencyInjectionValidatorFactory.php

示例13: getInstance

 /**
  * Returns the validator for the supplied constraint.
  *
  * @param Constraint $constraint A constraint
  *
  * @return ConstraintValidatorInterface A validator for the supplied constraint
  *
  * @throws ValidatorException      When the validator class does not exist
  * @throws UnexpectedTypeException When the validator is not an instance of ConstraintValidatorInterface
  */
 public function getInstance(Constraint $constraint)
 {
     $name = $constraint->validatedBy();
     if (!isset($this->validators[$name])) {
         if (!class_exists($name)) {
             throw new ValidatorException(sprintf('Constraint validator "%s" does not exist or it is not enabled. Check the "validatedBy" method in your constraint class "%s".', $name, get_class($constraint)));
         }
         $this->validators[$name] = new $name();
     } elseif (is_string($this->validators[$name])) {
         $this->validators[$name] = $this->container->get($this->validators[$name]);
     }
     if (!$this->validators[$name] instanceof ConstraintValidatorInterface) {
         throw new UnexpectedTypeException($this->validators[$name], 'Symfony\\Component\\Validator\\ConstraintValidatorInterface');
     }
     return $this->validators[$name];
 }
开发者ID:ayoah,项目名称:symfony,代码行数:26,代码来源:ConstraintValidatorFactory.php

示例14: getInstance

 /**
  * {@inheritDoc}
  */
 public function getInstance(Constraint $constraint)
 {
     $className = $constraint->validatedBy();
     // The second condition is a hack that is needed when CollectionValidator
     // calls itself recursively (Collection constraints can be nested).
     // Since the context of the validator is overwritten when initialize()
     // is called for the nested constraint, the outer validator is
     // acting on the wrong context when the nested validation terminates.
     //
     // A better solution - which should be approached in Symfony 3.0 - is to
     // remove the initialize() method and pass the context as last argument
     // to validate() instead.
     if (!isset($this->validators[$className]) || 'Symfony\\Component\\Validator\\Constraints\\CollectionValidator' === $className) {
         $this->validators[$className] = 'validator.expression' === $className ? new ExpressionValidator($this->propertyAccessor) : new $className();
     }
     return $this->validators[$className];
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:20,代码来源:ConstraintValidatorFactory.php

示例15: validatedBy

 /**
  * {@inheritdoc}
  */
 public function validatedBy()
 {
     return parent::validatedBy();
 }
开发者ID:ec-europa,项目名称:joinup-dev,代码行数:7,代码来源:EmailConstraint.php


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