Oauth2-server: ORM mapping for vendor-supplied traits

Created on 26 Apr 2018  路  5Comments  路  Source: thephpleague/oauth2-server

Hi guys

Not really specific to this project, but I hope you don't mind me asking here?

I wondered if anyone had a workaround for writing Doctrine mappings for the (very useful, thanks!) traits used on this project?

My org uses annotations so I don't want to move the whole project to Yaml mappings if I can avoid it. Neither do I want to scrawl all over your files (and thus break composer updates,) and neither do I want to copy & paste them somewhere else and then scrawl all over them.

The best we can come up with is to override all the trait properties (but keep the methods) - but that smells nasty.

Any better ideas please?

Cheers
Alex

Most helpful comment

You could find some inspiration here. AccessTokenEntity, for example. Fair warning though, it's a pretty old code..

All 5 comments

Personally, I don't use the traits at all (with the exception of AccessTokenTrait), and just implement the interfaces. It's all just getters and setters anyway, not difficult to implement yourself.

I'm afraid I can't help with regards to Doctrine as I don't use it myself. However I think the advice given by @lookyman is pretty spot on. I just wouldn't use the traits if they are causing you problems and implement the interfaces instead.

The traits aren't required to use the library, they are just handy implementations that you can use if applicable to your use case or for reference for your own implementations.

Either write your own traits or put the required functionality directly into your implementation and avoid using the provided traits altogether. The errors thrown if you've missed a required function for one of the interfaces should set you right.

Please let us know if this helps or if you have any further questions.

Yea that makes sense - traits more of a clue than a final implementation, thanks guys.

I'll just override the props for now to keep Doctrine happy (new to me too, but really easy to use once I had an example to copy,) and ditch the rest of the traits when/if we veer away from them.

Cheers

You could find some inspiration here. AccessTokenEntity, for example. Fair warning though, it's a pretty old code..

Handy, thank you. Implementing that scope finalizer was giving me a headache, so it was nice to lift yours :)

Was this page helpful?
0 / 5 - 0 ratings