コード例 #1
0
ファイル: XmlDriver.php プロジェクト: cubiche/cubiche
 /**
  * {@inheritdoc}
  */
 protected function addMetadataFor(\SimpleXMLElement $xmlRoot, MergeableClassMetadata $classMetadata)
 {
     foreach ($xmlRoot->xpath('//cubiche:valueobject') as $item) {
         // get the field tag
         $field = $item->xpath('..')[0];
         $fieldMapping = $this->getMappingAttributes($field);
         $fieldName = $fieldMapping['name'];
         $itemMapping = $this->getMappingAttributes($item);
         foreach ($item->attributes() as $key => $value) {
             $itemMapping[$key] = (string) $value;
         }
         if (!isset($itemMapping['type'])) {
             throw MappingException::inField('The cubiche:valueobject definition should have a "type" value', $classMetadata->name, $fieldName);
         }
         $valueObjectType = $itemMapping['type'];
         if ($field->getName() == 'field') {
             if (isset($fieldMapping['id']) && $fieldMapping['id'] !== false) {
                 throw MappingException::inField('The cubiche:valueobject configuration is only for field tags that is not an id', $classMetadata->name, $fieldName);
             }
             if (!isset($fieldMapping['type']) || isset($fieldMapping['type']) && $fieldMapping['type'] !== 'CubicheType') {
                 throw MappingException::inField('The cubiche:valueobject parent should have a "type" value equal to CubicheType', $classMetadata->name, $fieldName);
             }
             $propertyMetadata = new PropertyMetadata($classMetadata->name, $fieldName, 'valueobject');
             $propertyMetadata->setType($valueObjectType);
             $classMetadata->addPropertyMetadata($propertyMetadata);
         } else {
             throw MappingException::inField('The cubiche:valueobject configuration is only for field tags that is not an id', $classMetadata->name, $fieldName);
         }
     }
 }
コード例 #2
0
ファイル: MergeableDriver.php プロジェクト: cubiche/cubiche
 /**
  * @param \ReflectionClass $class
  */
 public function loadMetadataForClass(\ReflectionClass $class)
 {
     $classMetadata = new MergeableClassMetadata($class->getName());
     foreach ($this->drivers as $driver) {
         if (null !== ($metadata = $driver->loadMetadataForClass($class))) {
             $classMetadata->merge($metadata);
         }
     }
     return $classMetadata;
 }
コード例 #3
0
 public function loadMetadataForClass(\ReflectionClass $class)
 {
     $classMetadata = new MergeableClassMetadata($class->getName());
     foreach ($class->getProperties() as $property) {
         $field = $this->reader->getPropertyAnnotation($property, self::MOGRIFY);
         if (!is_null($field)) {
             $propertyMetadata = new MogrifyMetadata($class->getName(), $property->getName());
             $propertyMetadata->params = $field->params;
             $classMetadata->addPropertyMetadata($propertyMetadata);
         }
     }
     return $classMetadata;
 }
コード例 #4
0
ファイル: XmlDriver.php プロジェクト: sulu/sulu
 /**
  * {@inheritdoc}
  */
 protected function loadMetadataFromFile(\ReflectionClass $class, $file)
 {
     $classMetadata = new MergeableClassMetadata($class->getName());
     // load xml file
     // TODO xsd validation
     $xmlDoc = XmlUtils::loadFile($file);
     $xpath = new \DOMXPath($xmlDoc);
     $xpath->registerNamespace('x', 'http://schemas.sulu.io/class/general');
     $xpath->registerNamespace('list', 'http://schemas.sulu.io/class/list');
     foreach ($xpath->query('/x:class/x:properties/x:*') as $propertyNode) {
         $classMetadata->addPropertyMetadata($this->getPropertyMetadata($xpath, $propertyNode, $class->getName()));
     }
     return $classMetadata;
 }
コード例 #5
0
 public function loadMetadataForClass(\ReflectionClass $class)
 {
     $classMetadata = new MergeableClassMetadata($class->getName());
     foreach ($class->getProperties() as $reflectionProperty) {
         $propertyMetadata = new PropertyMetadata($class->getName(), $reflectionProperty->getName());
         $annotation = $this->reader->getPropertyAnnotation($reflectionProperty, 'Tapir\\AnnotationBundle\\Annotation\\Descripcion');
         if (null !== $annotation) {
             // Un @Descripcion fue encontrado
             $propertyMetadata->descripcion = $annotation->value;
         }
         $classMetadata->addPropertyMetadata($propertyMetadata);
     }
     return $classMetadata;
 }
コード例 #6
0
 /**
  * {@inheritdoc}
  */
 public function loadMetadataForClass(\ReflectionClass $class)
 {
     $classMetadata = new MergeableClassMetadata($class->getName());
     foreach ($class->getMethods() as $method) {
         $annotation = $this->reader->getMethodAnnotation($method, static::ANNOTATION_CLASS);
         if ($annotation instanceof LoggerAware) {
             $this->checkParameters($method, $annotation->getParameter());
             $propertyMetadata = new MethodMetadata($class->getName(), $method->getName());
             $propertyMetadata->setArgument($annotation->getParameter());
             $classMetadata->addMethodMetadata($propertyMetadata);
         }
     }
     return $classMetadata;
 }
コード例 #7
0
 /**
  * @inheritdoc
  */
 public function loadMetadataForClass(\ReflectionClass $class)
 {
     $classMetadata = new MergeableClassMetadata($class->getName());
     foreach ($class->getMethods() as $method) {
         $annotations = $this->reader->getMethodAnnotations($method);
         foreach ($annotations as $annotation) {
             if ($annotation instanceof Transactional) {
                 $propertyMetadata = new MethodMetadata($class->getName(), $method->getName());
                 $propertyMetadata->setEm($annotation->getEmName())->setOnError($annotation->getOnError())->setOnSuccess($annotation->getOnSuccess());
                 $classMetadata->addMethodMetadata($propertyMetadata);
             }
         }
     }
     return $classMetadata;
 }
 /**
  * {@inheritdoc}
  */
 public function loadMetadataForClass(\ReflectionClass $class)
 {
     $classMetadata = new MergeableClassMetadata($class->getName());
     foreach ($class->getProperties() as $reflectionProperty) {
         $propertyMetadata = new PropertyMetadata($class->getName(), $reflectionProperty->getName());
         /** @var \Integrated\Bundle\SlugBundle\Mapping\Annotations\Slug $annotation */
         $annotation = $this->reader->getPropertyAnnotation($reflectionProperty, 'Integrated\\Bundle\\SlugBundle\\Mapping\\Annotations\\Slug');
         if (null !== $annotation) {
             $propertyMetadata->slugFields = $annotation->fields;
             $propertyMetadata->slugSeparator = $annotation->separator;
         }
         $classMetadata->addPropertyMetadata($propertyMetadata);
     }
     return $classMetadata;
 }
コード例 #9
0
ファイル: ClassMetadata.php プロジェクト: Werkint/CacheBundle
 /**
  * @inheritdoc
  */
 public function merge(MergeableInterface $object)
 {
     parent::merge($object);
     if ($object instanceof ClassMetadata) {
         $this->setNamespace($object->getNamespace());
     }
 }
コード例 #10
0
 /**
  * {@inheritdoc}
  */
 public function loadMetadataForClass(\ReflectionClass $class)
 {
     $classMetadata = new MergeableClassMetadata($class->getName());
     foreach ($class->getMethods() as $method) {
         $annotation = $this->reader->getMethodAnnotation($method, static::ANNOTATION_CLASS);
         if ($annotation instanceof SemLock) {
             $propertyMetadata = new MethodMetadata($class->getName(), $method->getName());
             if (!$annotation->getKey()) {
                 throw new \Exception('Lock key not specified');
             }
             $propertyMetadata->setKey($annotation->getKey());
             $propertyMetadata->setWaitTimeout($annotation->getWaitTimeout());
             $classMetadata->addMethodMetadata($propertyMetadata);
         }
     }
     return $classMetadata;
 }
コード例 #11
0
ファイル: ClassMetadata.php プロジェクト: conjecto/nemrod
 /**
  * Merge metadata.
  *
  * @param MergeableInterface $object
  */
 public function merge(MergeableInterface $object)
 {
     parent::merge($object);
     $this->frame = $object->frame;
     $this->parentClasses = $object->parentClasses;
     $this->options = $object->options;
     $this->types = $object->types;
 }
コード例 #12
0
 public function merge(MergeableInterface $object)
 {
     if (!$object instanceof ClassMetadata) {
         throw new \InvalidArgumentException('object must be an instance of FSC\\HateoasBundle\\Metadata\\ClassMetadata.');
     }
     parent::merge($object);
     $this->relations = array_merge($this->relations, $object->getRelations());
 }
コード例 #13
0
 /**
  * {@inheritdoc}
  */
 public function merge(MergeableInterface $object)
 {
     if (!$object instanceof self) {
         throw new \InvalidArgumentException(sprintf('Object must be an instance of %s.', __CLASS__));
     }
     parent::merge($object);
     $this->relations = array_merge($this->relations, $object->getRelations());
     $this->relationProviders = array_merge($this->relationProviders, $object->getRelationProviders());
 }
コード例 #14
0
ファイル: ClassMetadata.php プロジェクト: exeu/objectmerger
 /**
  * {@inheritDoc}
  */
 public function merge(MergeableInterface $object)
 {
     if (!$object instanceof ClassMetadata) {
         throw new MetadataParseException();
     }
     parent::merge($object);
     if ($object->objectIdentifier !== null) {
         $this->objectIdentifier = $object->objectIdentifier;
     }
 }
コード例 #15
0
 /**
  * {@inheritdoc}
  */
 public function unserialize($str)
 {
     list($this->targetEntity, $translatable, $locale, $parent) = unserialize($str);
     parent::unserialize($parent);
     if ($translatable) {
         $this->translatable = $this->propertyMetadata[$translatable];
     }
     if ($locale) {
         $this->locale = $this->propertyMetadata[$locale];
     }
 }
コード例 #16
0
 public function testMerge()
 {
     $parentMetadata = new MergeableClassMetadata('Metadata\\Tests\\Fixtures\\TestParent');
     $parentMetadata->propertyMetadata['foo'] = 'bar';
     $parentMetadata->propertyMetadata['baz'] = 'baz';
     $parentMetadata->methodMetadata['foo'] = 'bar';
     $parentMetadata->createdAt = 2;
     $parentMetadata->fileResources[] = 'foo';
     $childMetadata = new MergeableClassMetadata('Metadata\\Tests\\Fixtures\\TestObject');
     $childMetadata->propertyMetadata['foo'] = 'baz';
     $childMetadata->methodMetadata['foo'] = 'baz';
     $childMetadata->createdAt = 1;
     $childMetadata->fileResources[] = 'bar';
     $parentMetadata->merge($childMetadata);
     $this->assertEquals('Metadata\\Tests\\Fixtures\\TestObject', $parentMetadata->name);
     $this->assertEquals('Metadata\\Tests\\Fixtures\\TestObject', $parentMetadata->reflection->name);
     $this->assertEquals(array('foo' => 'baz', 'baz' => 'baz'), $parentMetadata->propertyMetadata);
     $this->assertEquals(array('foo' => 'baz'), $parentMetadata->methodMetadata);
     $this->assertEquals(1, $parentMetadata->createdAt);
     $this->assertEquals(array('foo', 'bar'), $parentMetadata->fileResources);
 }
コード例 #17
0
ファイル: XmlDriver.php プロジェクト: cubiche/cubiche
 /**
  * {@inheritdoc}
  */
 protected function addMetadataForType($type, \SimpleXMLElement $xmlRoot, MergeableClassMetadata $classMetadata)
 {
     foreach ($xmlRoot->xpath('//cubiche:' . $type) as $item) {
         // get the field tag
         $field = $item->xpath('..')[0];
         $fieldMapping = $this->getMappingAttributes($field);
         $fieldName = $fieldMapping['name'];
         if ($field->getName() == 'field') {
             if (isset($fieldMapping['id']) && $fieldMapping['id'] !== false) {
                 throw MappingException::inField('The cubiche:' . $type . ' configuration is only for field tags that is not an id', $classMetadata->name, $fieldName);
             }
             if (!isset($fieldMapping['type']) || isset($fieldMapping['type']) && $fieldMapping['type'] !== 'CubicheType') {
                 throw MappingException::inField('The cubiche:' . $type . ' parent should have a "type" value equal to CubicheType', $classMetadata->name, $fieldName);
             }
             $propertyMetadata = new PropertyMetadata($classMetadata->name, $fieldName, $type);
             $classMetadata->addPropertyMetadata($propertyMetadata);
         } else {
             throw MappingException::inField('The cubiche:' . $type . ' configuration is only for id fields', $classMetadata->name, $fieldName);
         }
     }
 }
コード例 #18
0
 private function doAddPropertyMetadata(PsiPropertyMetadata $metadata)
 {
     parent::addPropertyMetadata($metadata);
     if (!$metadata->getRole()) {
         return;
     }
     if (isset($this->roles[$metadata->getRole()])) {
         $propertyName = $this->roles[$metadata->getRole()];
         throw new \InvalidArgumentException(sprintf('Role "%s" has already been assigned to property "%s" (on property "%s")', $metadata->getRole(), $propertyName, $metadata->getName()));
     }
     $this->roles[$metadata->getRole()] = $metadata->name;
 }
コード例 #19
0
ファイル: XmlDriver.php プロジェクト: cubiche/cubiche
 /**
  * {@inheritdoc}
  */
 protected function addMetadataFor(\SimpleXMLElement $xmlRoot, MergeableClassMetadata $classMetadata)
 {
     foreach ($xmlRoot->xpath('//cubiche:collection') as $item) {
         // get the field tag
         $field = $item->xpath('..')[0];
         $fieldMapping = $this->getMappingAttributes($field);
         $fieldName = isset($fieldMapping['name']) ? $fieldMapping['name'] : $fieldMapping['field'];
         $itemMapping = $this->getMappingAttributes($item, array('of' => null));
         if (!isset($itemMapping['type'])) {
             throw MappingException::inField('The cubiche:collection definition should have a "type" value', $classMetadata->name, $fieldName);
         }
         $collectionType = $itemMapping['type'];
         $collectionOf = $itemMapping['of'];
         if ($field->getName() == 'field') {
             if (isset($fieldMapping['id']) && $fieldMapping['id'] !== false) {
                 throw MappingException::inField('The cubiche:collection configuration is only for field tags that is not an id', $classMetadata->name, $fieldName);
             }
             if (!isset($fieldMapping['type']) || isset($fieldMapping['type']) && $fieldMapping['type'] !== 'CubicheType') {
                 throw MappingException::inField('The cubiche:collection parent should have a "type" value equal to CubicheType', $classMetadata->name, $fieldName);
             }
             $propertyMetadata = new CollectionPropertyMetadata($classMetadata->name, $fieldName);
             $propertyMetadata->setType($collectionType);
             $propertyMetadata->setOf($collectionOf);
             $classMetadata->addPropertyMetadata($propertyMetadata);
         } elseif ($field->getName() == 'embed-many' || $field->getName() == 'reference-many') {
             if (isset($fieldMapping['field'])) {
                 $field = $fieldMapping['field'];
             } else {
                 throw MappingException::inField('Cannot infer a field', $classMetadata->name, $fieldName);
             }
             $propertyMetadata = new CollectionPropertyMetadata($classMetadata->name, $field);
             $propertyMetadata->setType($collectionType);
             $classMetadata->addPropertyMetadata($propertyMetadata);
         } else {
             throw MappingException::inField('The cubiche:collection configuration is only for field, embed-many or reference-many tags', $classMetadata->name, $fieldName);
         }
     }
 }
コード例 #20
0
 /**
  * {@inheritdoc}
  */
 public function unserialize($str)
 {
     list($this->targetEntity, $currentLocale, $fallbackLocale, $translations, $parent) = unserialize($str);
     parent::unserialize($parent);
     if ($currentLocale) {
         $this->currentLocale = $this->propertyMetadata[$currentLocale];
     }
     if ($fallbackLocale) {
         $this->fallbackLocale = $this->propertyMetadata[$fallbackLocale];
     }
     if ($translations) {
         $this->translations = $this->propertyMetadata[$translations];
     }
 }
コード例 #21
0
 public function merge(MergeableInterface $metadata)
 {
     if (!$metadata instanceof ClassMetadata) {
         throw new InvalidArgumentException('$metadata must be an instance of ClassMetadata.');
     }
     foreach ($this->methodMetadata as $name => $methodMetadata) {
         // check if metadata was declared on an interface
         if (!$metadata->reflection->hasMethod($name)) {
             continue;
         }
         if ($metadata->reflection->getMethod($name)->getDeclaringClass()->name !== $methodMetadata->class) {
             if (!isset($metadata->methodMetadata[$name])) {
                 if ($methodMetadata->reflection->isAbstract()) {
                     continue;
                 }
                 throw new RuntimeException(sprintf('You have overridden a secured method "%s::%s" in "%s". ' . 'Please copy over the applicable security metadata, and ' . 'also add @SatisfiesParentSecurityPolicy.', $methodMetadata->reflection->class, $name, $metadata->reflection->name));
             }
             if (!$metadata->methodMetadata[$name]->satisfiesParentSecurityPolicy) {
                 throw new RuntimeException(sprintf('Unresolved security metadata conflict for method "%s::%s" in "%s". Please copy the respective annotations, and add @SatisfiesParentSecurityPolicy to the child method.', $metadata->reflection->name, $name, $methodMetadata->reflection->getDeclaringClass()->getFilename()));
             }
         }
     }
     parent::merge($metadata);
 }
コード例 #22
0
ファイル: ClassMetadata.php プロジェクト: hykz/Depot
 public function unserialize($str)
 {
     list($this->preSerializeMethods, $this->postSerializeMethods, $this->postDeserializeMethods, $this->xmlRootName, $this->accessorOrder, $this->customOrder, $parentStr) = unserialize($str);
     parent::unserialize($parentStr);
 }
コード例 #23
0
ファイル: ClassMetadata.php プロジェクト: ygeneration666/ma
 public function unserialize($str)
 {
     list($this->preSerializeMethods, $this->postSerializeMethods, $this->postDeserializeMethods, $this->xmlRootName, $this->xmlRootNamespace, $this->xmlNamespaces, $this->accessorOrder, $this->customOrder, $this->handlerCallbacks, $this->discriminatorDisabled, $this->discriminatorBaseClass, $this->discriminatorFieldName, $this->discriminatorValue, $this->discriminatorMap, $parentStr) = unserialize($str);
     parent::unserialize($parentStr);
 }
コード例 #24
0
ファイル: ClassMetadata.php プロジェクト: novaway/open-graph
 /**
  * Constructor
  *
  * @param string $name
  */
 public function __construct($name)
 {
     parent::__construct($name);
     $this->namespaces = [];
     $this->nodes = [];
 }
コード例 #25
0
 public function unserialize($str)
 {
     list($this->schema, $this->inherit, $parentStr) = unserialize($str);
     parent::unserialize($parentStr);
 }
コード例 #26
0
ファイル: ClassMetadata.php プロジェクト: conjecto/nemrod
 /**
  * Merge metadata.
  *
  * @param MergeableInterface $object
  */
 public function merge(MergeableInterface $object)
 {
     parent::merge($object);
     $this->types = array_merge($this->types, $object->types);
     $this->uriPattern = $object->uriPattern;
 }
コード例 #27
0
 /**
  * {@inheritdoc}
  */
 public function unserialize($str)
 {
     list($this->resource, $this->idField, $this->relationships, $parentStr) = unserialize($str);
     parent::unserialize($parentStr);
 }
コード例 #28
0
 /**
  * Merges another ClassMetadata into the current metadata.
  *
  * Caution: the registered token providers will be overriden when the new
  * ClassMetadata has a token provider with the same name.
  *
  * The URL schema will be overriden, you can use {parent} to refer to the
  * previous URL schema.
  *
  * @param ClassMetadata $metadata
  */
 public function merge(MergeableInterface $metadata)
 {
     parent::merge($metadata);
     $this->uriSchema = str_replace('{parent}', $this->uriSchema, $metadata->getUriSchema());
     foreach ($metadata->getTokenProviders() as $tokenName => $provider) {
         $this->addTokenProvider($tokenName, $provider, true);
     }
     if ($defunctRouteHandler = $metadata->getDefunctRouteHandler()) {
         $this->setDefunctRouteHandler($defunctRouteHandler);
     }
     if ($conflictResolver = $metadata->getConflictResolver()) {
         $this->setConflictResolver($conflictResolver);
     }
 }
コード例 #29
0
ファイル: EntityMetadata.php プロジェクト: Maksold/platform
 /**
  * {@inheritdoc}
  */
 public function unserialize($str)
 {
     list($this->configurable, $this->defaultValues, $this->routeName, $this->routeView, $this->routeCreate, $this->mode, $parentStr) = unserialize($str);
     parent::unserialize($parentStr);
 }
コード例 #30
0
ファイル: ClassMetadata.php プロジェクト: jmcclell/Hateoas
 /**
  * {@inheritDoc}
  */
 public function unserialize($str)
 {
     list($this->relations, $this->relationProviders, $parentStr) = unserialize($str);
     parent::unserialize($parentStr);
 }