/**
  * {@inheritdoc}
  */
 public function loadMetadata()
 {
     $factory = new SerializationClassMetadataFactory();
     $cache = $this->getMetadataCache();
     $collection = new SerializationMetadataCollection();
     foreach ($cache as $className => $parameters) {
         $metadata = $factory->create($className, $parameters);
         $collection->add($metadata);
     }
     return $collection;
 }
 /**
  * Returns the serialization metadata for given entity
  *
  * @param object $entity
  *
  * @return \WellCommerce\Bundle\ApiBundle\Metadata\SerializationClassMetadataInterface
  */
 protected function getSerializationMetadata($entity)
 {
     $className = $this->getRealClass($entity);
     return $this->serializationMetadataCollection->get($className);
 }