/**
  * Constructor.
  *
  * @param  EntityManager $manager
  * @param  Metadata      $metadata
  * @param  array         $mapping
  */
 public function __construct(EntityManager $manager, Metadata $metadata, array $mapping)
 {
     $this->manager = $manager;
     $this->metadata = $metadata;
     if (!($this->name = $mapping['name'])) {
         throw new \InvalidArgumentException('The parameter "name" may not be omitted in relations.');
     }
     $this->targetEntity = $mapping['targetEntity'];
     $this->targetRepository = $manager->getRepository($this->targetEntity);
     $this->targetMetadata = $this->targetRepository->getMetadata();
 }