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


PHP Constraint::getTargets方法代碼示例

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


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

示例1: addConstraint

 /**
  * {@inheritDoc}
  */
 public function addConstraint(Constraint $constraint)
 {
     if (!in_array(Constraint::CLASS_CONSTRAINT, (array) $constraint->getTargets())) {
         throw new ConstraintDefinitionException(sprintf('The constraint %s cannot be put on classes', get_class($constraint)));
     }
     $constraint->addImplicitGroupName($this->getDefaultGroup());
     parent::addConstraint($constraint);
 }
開發者ID:nickaggarwal,項目名稱:sample-symfony2,代碼行數:11,代碼來源:ClassMetadata.php

示例2: addConstraint

 /**
  * {@inheritdoc}
  */
 public function addConstraint(Constraint $constraint)
 {
     if (!in_array(Constraint::PROPERTY_CONSTRAINT, (array) $constraint->getTargets())) {
         throw new ConstraintDefinitionException(sprintf('The constraint %s cannot be put on properties or getters', get_class($constraint)));
     }
     parent::addConstraint($constraint);
     return $this;
 }
開發者ID:Ener-Getick,項目名稱:symfony,代碼行數:11,代碼來源:MemberMetadata.php

示例3:

 function it_doesnt_support_multi_targets_constraint($guesser, $factory, ClassMetadata $metadata, ProductValueInterface $value, AttributeInterface $attribute, Constraint $multiTargets, Constraint $validNumber)
 {
     $factory->createMetadata(Argument::any())->willReturn($metadata);
     $value->getAttribute()->willReturn($attribute);
     $attribute->getBackendType()->willReturn('varchar');
     $guesser->guessConstraints($attribute)->willReturn([$multiTargets]);
     $multiTargets->getTargets()->willReturn([Constraint::PROPERTY_CONSTRAINT, Constraint::CLASS_CONSTRAINT]);
     $this->shouldThrow(new \LogicException('No support provided for constraint on many targets'))->duringGetMetadataFor($value);
 }
開發者ID:ashutosh-srijan,項目名稱:findit_akeneo,代碼行數:9,代碼來源:ProductValueMetadataFactorySpec.php

示例4: addConstraint

 /**
  * @param ClassMetadata      $metadata
  * @param Constraint         $constraint
  * @param AttributeInterface $attribute
  */
 protected function addConstraint(ClassMetadata $metadata, Constraint $constraint, AttributeInterface $attribute)
 {
     $target = $constraint->getTargets();
     if (is_array($target)) {
         throw new \LogicException('No support provided for constraint on many targets');
     } elseif (Constraint::PROPERTY_CONSTRAINT === $target) {
         $metadata->addPropertyConstraint($attribute->getBackendType(), $constraint);
     } elseif (Constraint::CLASS_CONSTRAINT === $target) {
         $metadata->addConstraint($constraint);
     }
 }
開發者ID:vpetrovych,項目名稱:pim-community-dev,代碼行數:16,代碼來源:ProductValueMetadataFactory.php

示例5: addConstraint

 /**
  * {@inheritDoc}
  */
 public function addConstraint(Constraint $constraint)
 {
     if (!in_array(Constraint::PROPERTY_CONSTRAINT, (array) $constraint->getTargets())) {
         throw new ConstraintDefinitionException(sprintf('The constraint %s cannot be put on properties or getters', get_class($constraint)));
     }
     if ($constraint instanceof Valid) {
         $this->cascaded = true;
         $this->collectionCascaded = $constraint->traverse;
     } else {
         parent::addConstraint($constraint);
     }
     return $this;
 }
開發者ID:nickaggarwal,項目名稱:sample-symfony2,代碼行數:16,代碼來源:MemberMetadata.php

示例6: addConstraint

 /**
  * {@inheritdoc}
  */
 public function addConstraint(Constraint $constraint)
 {
     if (!in_array(Constraint::CLASS_CONSTRAINT, (array) $constraint->getTargets())) {
         throw new ConstraintDefinitionException(sprintf('The constraint "%s" cannot be put on classes.', get_class($constraint)));
     }
     if ($constraint instanceof Valid) {
         throw new ConstraintDefinitionException(sprintf('The constraint "%s" cannot be put on classes.', get_class($constraint)));
     }
     if ($constraint instanceof Traverse) {
         if ($constraint->traverse) {
             // If traverse is true, traversal should be explicitly enabled
             $this->traversalStrategy = TraversalStrategy::TRAVERSE;
         } else {
             // If traverse is false, traversal should be explicitly disabled
             $this->traversalStrategy = TraversalStrategy::NONE;
         }
         // The constraint is not added
         return $this;
     }
     $constraint->addImplicitGroupName($this->getDefaultGroup());
     parent::addConstraint($constraint);
     return $this;
 }
開發者ID:carlostopo,項目名稱:prueba_runator,代碼行數:26,代碼來源:ClassMetadata.php


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