Blake
Blake

Reputation: 1741

Doctrine Default Annotation Namespace in Zend Framework 2

I'm trying to embark on ZF2 since they've moved to RC status. Everything is going smoothly, but I'd like to set a default namespace for annotations so I can use @Table instead of @Doctrine\ORM\Mapping\Table or @ORM\Table.

From what I can tell reading the Doctrine module's documentation in their readme on Github, there is no option that allows you to specify default namespaces to the reader or even specify your own reader class. Does anyone know if this option is simply missing at this time? Or is there something I'm not seeing?

Upvotes: 0

Views: 528

Answers (2)

superdweebie
superdweebie

Reputation: 1576

As @Sam said, use statements are the normal way to handle annotation namespaces.

If you want to use a different Annotation Reader, then write a new DriverFactory to replace the one that ships with DoctrineModule, and override the module config so that your new factory is used. (If you think your new factory might be useful to others, feel free to put in a PR against DoctrineModule and share)

Upvotes: 1

Sam
Sam

Reputation: 16455

As far as i know the Annotations are defined by the way you handle the use-statements of your class. Currently you do use Doctrine\ORM\Mapping as ORM so the annotation grabs @ORM and everything past that is simply concatenated.

So @ORM\Table becomes Doctrime\ORM\Mapping\Table

My guess - but i haven't tested this - if you include the Table class via use Doctrine\ORM\Mapping\Table that @Table would work. Just a humble guess though. As you've pointed out, there are not all too many ressources for ZF2 Implementations, yet, and quality of life features always come last ;)

Upvotes: 1

Related Questions