/**
  * @inheritdoc
  */
 public function merge(MergeableInterface $object)
 {
     parent::merge($object);
     if ($object instanceof ClassMetadata) {
         $this->setNamespace($object->getNamespace());
     }
 }
 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());
 }
Exemple #3
0
 /**
  * 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;
 }
Exemple #4
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());
 }
Exemple #5
0
 /**
  * @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;
 }
Exemple #6
0
 /**
  * {@inheritDoc}
  */
 public function merge(MergeableInterface $object)
 {
     if (!$object instanceof ClassMetadata) {
         throw new MetadataParseException();
     }
     parent::merge($object);
     if ($object->objectIdentifier !== null) {
         $this->objectIdentifier = $object->objectIdentifier;
     }
 }
Exemple #7
0
 /**
  * {@inheritdoc}
  */
 public function merge(MergeableInterface $object)
 {
     parent::merge($object);
     if ($object instanceof EntityMetadata) {
         $this->configurable = $object->configurable;
         $this->defaultValues = $object->defaultValues;
         $this->routeName = $object->routeName;
         $this->routeView = $object->routeView;
         $this->routeCreate = $object->routeCreate;
         $this->mode = $object->mode;
     }
 }
Exemple #8
0
 public function merge(MergeableInterface $object)
 {
     if (!$object instanceof ClassMetadata) {
         throw new InvalidArgumentException('$object must be an instance of ClassMetadata.');
     }
     parent::merge($object);
     $this->preSerializeMethods = array_merge($this->preSerializeMethods, $object->preSerializeMethods);
     $this->postSerializeMethods = array_merge($this->postSerializeMethods, $object->postSerializeMethods);
     $this->postDeserializeMethods = array_merge($this->postDeserializeMethods, $object->postDeserializeMethods);
     $this->xmlRootName = $object->xmlRootName;
     if ($object->accessorOrder) {
         $this->accessorOrder = $object->accessorOrder;
         $this->customOrder = $object->customOrder;
     }
     $this->sortProperties();
 }
 /**
  * {@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);
     if ($object->targetEntity) {
         $this->targetEntity = $object->targetEntity;
     }
     if ($object->translatable) {
         $this->translatable = $object->translatable;
     }
     if ($object->locale) {
         $this->locale = $object->locale;
     }
 }
 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);
 }
 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);
 }
Exemple #12
0
 public function merge(MergeableInterface $object)
 {
     if (!$object instanceof ClassMetadata) {
         throw new InvalidArgumentException('$object must be an instance of ClassMetadata.');
     }
     parent::merge($object);
     $this->preSerializeMethods = array_merge($this->preSerializeMethods, $object->preSerializeMethods);
     $this->postSerializeMethods = array_merge($this->postSerializeMethods, $object->postSerializeMethods);
     $this->postDeserializeMethods = array_merge($this->postDeserializeMethods, $object->postDeserializeMethods);
     $this->xmlRootName = $object->xmlRootName;
     $this->xmlRootNamespace = $object->xmlRootNamespace;
     $this->xmlNamespaces = array_merge($this->xmlNamespaces, $object->xmlNamespaces);
     // Handler methods are taken from the outer class completely.
     $this->handlerCallbacks = $object->handlerCallbacks;
     if ($object->accessorOrder) {
         $this->accessorOrder = $object->accessorOrder;
         $this->customOrder = $object->customOrder;
     }
     if ($object->discriminatorFieldName && $this->discriminatorFieldName) {
         throw new \LogicException(sprintf('The discriminator of class "%s" would overwrite the discriminator of the parent class "%s". Please define all possible sub-classes in the discriminator of %s.', $object->name, $this->discriminatorBaseClass, $this->discriminatorBaseClass));
     }
     if ($this->discriminatorMap && !$this->reflection->isAbstract()) {
         if (false === ($typeValue = array_search($this->name, $this->discriminatorMap, true))) {
             throw new \LogicException(sprintf('The sub-class "%s" is not listed in the discriminator of the base class "%s".', $this->name, $this->discriminatorBaseClass));
         }
         $this->discriminatorValue = $typeValue;
         if (isset($this->propertyMetadata[$this->discriminatorFieldName]) && !$this->propertyMetadata[$this->discriminatorFieldName] instanceof StaticPropertyMetadata) {
             throw new \LogicException(sprintf('The discriminator field name "%s" of the base-class "%s" conflicts with a regular property of the sub-class "%s".', $this->discriminatorFieldName, $this->discriminatorBaseClass, $this->name));
         }
         $discriminatorProperty = new StaticPropertyMetadata($this->name, $this->discriminatorFieldName, $typeValue);
         $discriminatorProperty->serializedName = $this->discriminatorFieldName;
         $this->propertyMetadata[$this->discriminatorFieldName] = $discriminatorProperty;
     }
     $this->sortProperties();
 }
Exemple #13
0
 /**
  * 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;
 }
 public function merge(MergeableInterface $object)
 {
     if (!$object instanceof ClassMetadata) {
         throw new InvalidArgumentException('$object must be an instance of ClassMetadata.');
     }
     parent::merge($object);
     $this->preSerializeMethods = array_merge($this->preSerializeMethods, $object->preSerializeMethods);
     $this->postSerializeMethods = array_merge($this->postSerializeMethods, $object->postSerializeMethods);
     $this->postDeserializeMethods = array_merge($this->postDeserializeMethods, $object->postDeserializeMethods);
     $this->xmlRootName = $object->xmlRootName;
     $this->xmlRootNamespace = $object->xmlRootNamespace;
     $this->xmlNamespaces = array_merge($this->xmlNamespaces, $object->xmlNamespaces);
     // Handler methods are taken from the outer class completely.
     $this->handlerCallbacks = $object->handlerCallbacks;
     if ($object->accessorOrder) {
         $this->accessorOrder = $object->accessorOrder;
         $this->customOrder = $object->customOrder;
     }
     if ($object->discriminatorFieldName && $this->discriminatorFieldName) {
         throw new \LogicException(sprintf('The discriminator of class "%s" would overwrite the discriminator of the parent class "%s". Please define all possible sub-classes in the discriminator of %s.', $object->name, $this->discriminatorBaseClass, $this->discriminatorBaseClass));
     }
     // In case discrimination class is in the middle of hierarchy
     if ($object->discriminatorMap) {
         $this->discriminatorFieldName = $object->discriminatorFieldName;
         $this->discriminatorMap = $object->discriminatorMap;
         $this->discriminatorBaseClass = $object->discriminatorBaseClass;
     }
     if ($this->discriminatorMap && !$this->reflection->isAbstract()) {
         if (false === ($typeValue = array_search($this->name, $this->discriminatorMap, true))) {
             throw new \LogicException(sprintf('The sub-class "%s" is not listed in the discriminator of the base class "%s".', $this->name, $this->discriminatorBaseClass));
         }
         $this->discriminatorValue = $typeValue;
         // TODO: Получение мета-данных для дискриминатора, надо также сделать и для десериализации,
         // TODO: дабы избавиться от костыля в GraphNavigator->resolveMetadata для XML-атрибутов.
         if (isset($this->propertyMetadata[$this->discriminatorFieldName])) {
             $discriminatorProperty = $this->propertyMetadata[$this->discriminatorFieldName];
         } else {
             $discriminatorProperty = new StaticPropertyMetadata($this->name, $this->discriminatorFieldName, $typeValue);
             $discriminatorProperty->serializedName = $this->discriminatorFieldName;
         }
         $this->propertyMetadata[$this->discriminatorFieldName] = $discriminatorProperty;
     }
     $this->sortProperties();
 }
 public function merge(MergeableInterface $object)
 {
     parent::merge($object);
     /** @var ClassMetadata $object */
     $this->routes = array_merge($this->routes, $object->routes);
 }
 /**
  * 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);
     foreach ($metadata->getAutoRouteDefinitions() as $definitionName => $definition) {
         if (isset($this->definitions[$definitionName])) {
             $this->definitions[$definitionName]->merge($definition);
             continue;
         }
         $this->definitions[$definitionName] = $definition;
     }
     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);
     }
 }
 /**
  * {@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->resource = $object->getResource();
     $this->idField = $object->getIdField();
     foreach ($object->getRelationships() as $relationship) {
         $this->addRelationship($relationship);
     }
 }
 /**
  * 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);
     }
 }