Maxime Picard
Maxime Picard

Reputation: 683

Find all entity fields with a specific @Annotation

I want to retrieve all my fields that have the annotation @Translatable in an entity, for example :

class WonderfulClass
{    
    /**
     * @var string
     * @Gedmo\Translatable
     */
    private $aField;

    /**
     * @var string
     * @Gedmo\Translatable
     */
    private $otherField;

    /**
     * @var string
     */
    private $lastField;

In this case, I want to retrieve fields that have the @Gedmo\Translatable annotation ($aField and $otherField).

Does somebody knows how to do this ?

Upvotes: 5

Views: 3304

Answers (1)

Christophe Willemsen
Christophe Willemsen

Reputation: 20185

You can use the Doctrine Annotations Reader : https://github.com/doctrine/annotations

Or read the DocComments with the native PHP Reflection Class : http://php.net/manual/en/reflectionclass.getdoccomment.php

Upvotes: 3

Related Questions