コード例 #1
0
 /**
  * @param string $name
  * @return array|object
  */
 public function getConstraintsForField($name)
 {
     $constraintsMetadata = $this->constraintsMetadata;
     $className = $constraintsMetadata->getClass();
     while (count($parts = explode('.', $name, 2)) > 1) {
         $classMetadata = $this->classMetadataFactory->getMetadataFor($className);
         $className = $classMetadata->getAssociationTargetClass($parts[0]);
         $constraintsMetadata = $this->constraintsMetadataFactory->getMetadataFor($className);
         $name = $parts[1];
     }
     return $constraintsMetadata->getConstraintsForField($name);
 }
コード例 #2
0
ファイル: FormConfig.php プロジェクト: mike227/n-forms
 /**
  * @throws \NForms\Exceptions\InvalidStateException
  * @return NULL|IConstraintMetadata
  */
 private function getConstraintMetadata()
 {
     if (!$this->_constraintMetadata) {
         if (!$this->constraintMetadataFactory) {
             return NULL;
         } elseif (!$this->targetClass) {
             throw new InvalidStateException("Please, set container className.");
         }
         $this->_constraintMetadata = $this->constraintMetadataFactory->getMetadataFor($this->targetClass, $this->getValidationGroups());
     }
     return $this->_constraintMetadata;
 }
コード例 #3
0
 /**
  * @param string $className
  * @param array|null $validationGroups
  * @return NULL|IConstraintMetadata
  */
 public function getMetadataFor($className, array $validationGroups = NULL)
 {
     return new ConstraintMetadataWrapper($this->constraintsMetadataFactory, $this->constraintsMetadataFactory->getMetadataFor($className, $validationGroups), $this->classMetadataFactory);
 }