Skip to content

Commit

Permalink
Merge pull request #22 from qooplmao/merge-class-metadata
Browse files Browse the repository at this point in the history
Merge class metadata when extending classes
  • Loading branch information
koemeet committed May 6, 2016
2 parents 2deaa50 + 47660ae commit 424c41a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Configuration/Metadata/ClassMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Mango\Bundle\JsonApiBundle\Configuration\Relationship;
use Mango\Bundle\JsonApiBundle\Configuration\Resource;
use Metadata\MergeableClassMetadata;
use Metadata\MergeableInterface;

/**
* @author Steffen Brem <[email protected]>
Expand Down Expand Up @@ -104,6 +105,25 @@ public function addRelationship($relationship)
$this->relationships->add($relationship);
}

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

/**
* {@inheritdoc}
*/
Expand Down

0 comments on commit 424c41a

Please sign in to comment.