In my Symfony2/doctrine2 application, I have two entities, Media and Recipe.

They can be linked by a oneToMany or a ManyToMany association.

In the case of a oneToMany relationship, I am using the following code to retrieve the Recipe linked to an instance of Media :

```
$accessor = PropertyAccess::createPropertyAccessor();
$reflect = new ReflectionClass($media);
$shortName =  $reflect->getShortName();
$value = $accessor->getValue($element, $shortName);

```

However, if the relationship is a manyToMany, and also if I gave a custom name to the property, the previous code does not work.

How can I programatically retrieve the "recipes" of the mappedBy from the annotation mapping of the Media class ?

```
/**
 * @ORM\OrderBy({"sortablePosition" = "ASC"})
 * @Assert\Valid()
 * @ORM\ManyToMany(targetEntity="\AppBundle\Entity\Core\Media", mappedBy="recipes", cascade={"persist", "remove"})
 */
protected $medias;

```