/** * @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); }
/** * @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; }
/** * @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); }