コード例 #1
0
ファイル: GraphWalker.php プロジェクト: netixpro/symfony
 protected function walkMember(MemberMetadata $metadata, $value, $group, $propertyPath)
 {
     $this->context->setCurrentProperty($metadata->getPropertyName());
     foreach ($metadata->findConstraints($group) as $constraint) {
         $this->walkConstraint($constraint, $value, $group, $propertyPath);
     }
 }
コード例 #2
0
ファイル: GraphWalker.php プロジェクト: janmarek/Neuron
 protected function walkMember(MemberMetadata $metadata, $value, $group, $propertyPath, $propagatedGroup = null)
 {
     $this->context->setCurrentProperty($metadata->getPropertyName());
     foreach ($metadata->findConstraints($group) as $constraint) {
         $this->walkConstraint($constraint, $value, $group, $propertyPath);
     }
     if ($metadata->isCascaded()) {
         $this->walkReference($value, $propagatedGroup ?: $group, $propertyPath);
     }
 }
コード例 #3
0
 /**
  * Constructor.
  *
  * @param string $class The class this property is defined on
  * @param string $name  The name of this property
  */
 public function __construct($class, $name)
 {
     if (!property_exists($class, $name)) {
         throw new ValidatorException(sprintf('Property %s does not exists in class %s', $name, $class));
     }
     parent::__construct($class, $name, $name);
 }
コード例 #4
0
ファイル: GetterMetadata.php プロジェクト: netvlies/symfony
 /**
  * Constructor.
  *
  * @param string $class    The class the getter is defined on
  * @param string $property The property which the getter returns
  */
 public function __construct($class, $property)
 {
     $getMethod = 'get' . ucfirst($property);
     $isMethod = 'is' . ucfirst($property);
     if (method_exists($class, $getMethod)) {
         $method = $getMethod;
     } elseif (method_exists($class, $isMethod)) {
         $method = $isMethod;
     } else {
         throw new ValidatorException(sprintf('Neither method %s nor %s exists in class %s', $getMethod, $isMethod, $class));
     }
     parent::__construct($class, $method, $property);
 }
コード例 #5
0
ファイル: ClassMetadata.php プロジェクト: gr-thao/jobeet
 /**
  * Adds a member metadata.
  *
  * @param MemberMetadata $metadata
  */
 protected function addMemberMetadata(MemberMetadata $metadata)
 {
     $property = $metadata->getPropertyName();
     $this->members[$property][] = $metadata;
 }
コード例 #6
0
 protected function walkMember(MemberMetadata $metadata, $value, $group, $propertyPath, $propagatedGroup = null)
 {
     $metadata->accept($this->visitor, $value, $group, $propertyPath, $propagatedGroup);
 }
コード例 #7
0
ファイル: ClassMetadata.php プロジェクト: Gregwar/symfony
 /**
  * Adds a member metadata
  *
  * @param MemberMetadata $metadata
  */
 protected function addMemberMetadata(MemberMetadata $metadata)
 {
     $property = $metadata->getPropertyName();
     if (!isset($this->members[$property])) {
         $this->members[$property] = array();
     }
     $this->members[$property][] = $metadata;
 }
コード例 #8
0
ファイル: GraphWalker.php プロジェクト: laubosslink/lab
 protected function walkMember(MemberMetadata $metadata, $value, $group, $propertyPath, $propagatedGroup = null)
 {
     $currentClass = $metadata->getClassName();
     $currentProperty = $metadata->getPropertyName();
     foreach ($metadata->findConstraints($group) as $constraint) {
         $this->walkConstraint($constraint, $value, $group, $propertyPath, $currentClass, $currentProperty);
     }
     if ($metadata->isCascaded()) {
         $this->walkReference($value, $propagatedGroup ?: $group, $propertyPath, $metadata->isCollectionCascaded(), $metadata->isCollectionCascadedDeeply());
     }
 }
コード例 #9
0
 /**
  * @param MemberMetadata $propertyMetadata
  * @param mixed $dataSource
  * @param string $dataSourceClass
  * @return null|array
  */
 protected function findPropertyDataTypeInfo(MemberMetadata $propertyMetadata, $dataSource, $dataSourceClass)
 {
     if ($dataSource !== null) {
         $dataSource = $propertyMetadata->getReflectionMember($dataSourceClass)->getValue($dataSource);
         if (is_array($dataSource) || $dataSource instanceof \ArrayAccess) {
             return array(null, $dataSource);
         }
         if (is_object($dataSource)) {
             return array(get_class($dataSource), $dataSource);
         }
         return null;
     }
     // Since there is no datasource we need another way to determin the properties class
     foreach ($propertyMetadata->getConstraints() as $constraint) {
         if (!$constraint instanceof Type) {
             continue;
         }
         $type = strtolower($constraint->type);
         $type = $type == 'boolean' ? 'bool' : $constraint->type;
         $isFunction = 'is_' . $type;
         $ctypeFunction = 'ctype_' . $type;
         if (function_exists($isFunction) || function_exists($ctypeFunction)) {
             return null;
         }
         return array($constraint->type, null);
     }
     return null;
 }