schmittjoh / JMSAopBundle

Adds AOP capabilities to Symfony
200 stars 53 forks source link

Documentation: How to use @Transactional annotation. #5

Closed renoirb closed 1 year ago

renoirb commented 12 years ago

I am trying to use as the documentation explain and set in an entity a transaction using the @Transactional annotation.

But I cannot see how to make it work.

I am fairly new to Symfony2 and Dependency Injection and the bundle seem very powerful, but I cannot find a way around to actually use the transaction pointcut/interceptor into the project.

robertfausk commented 12 years ago

+1

alsar commented 12 years ago

If you followed the tutorial http://jmsyst.com/bundles/JMSAopBundle#transaction-management, it should work without any problems. Where did you stuck?

adrian-ludwig commented 12 years ago

By the way. This Transaction Managment Annotation doesnt work with OAuthv2-php. But its propobly mater of Annotation Reader

mmucklo commented 7 years ago

I think part of the confusion is over how the @DI... tags are working, plus how annotations work in general.

To do something similar I had to create a separate Annotation class (annotated with @Annotation - see https://techpunch.co.uk/development/custom-annotations-in-symfony2-using-doctrine2s-annotation-classes except make the @Target point to "METHOD"), and then in the methodMatches look for that class with a full class name -

Example:

return null !== $this->read->getMethodAnnotation($method,'SomethingBundle\Annotation\MyAnnotation');

Then I dropped in the services into service.yml as in the first examples and it seems to work.