Symfony2 & Doctrine2: creating custom annotations

I would like to create some custom annotations for the Entity class, I came across this article about Doctrine2 , however I'm not sure how to integrate this into my Symfony bundle, can anyone shed some light on this?

class User implements UserInterface { /** * @var integer $id * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") * * @myCustomVar(remember="true") */ protected $id; 

thanks

+6
source share
1 answer

Inspire you to expand the doctrine:

  • The DoctrineExtensions library contains some annotation classes. But since these annotations mean nothing to the core of the Doctrine, it is also an extension that is responsible for interpreting them. To do this, it uses some listeners that must be registered with the Doctrine event manager.

  • In Symfony, you can declare services with doctrine.event_listener (or doctrine.event_subscriber for event subscribers), so the Doctrine package will find them and register them for you. The StofDoctrineExtensionsBundle is primarily aimed at automating the registration of this part of the registration of event listeners.

In any case, when you think about the extension of the Doctrine, since it can be used without Symfony, prefer to divide your work into two parts: one is the extension of the doctrine, the other is the glue between this extension and Symfony and is called a package.

+6
source

Source: https://habr.com/ru/post/902569/


All Articles