-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom annotation classes #4
Comments
Let me know if you want a PR :) |
See #5 |
Another use case: |
I'm excited about the new ideas you come with and I also like the idea of the interface but I think it should be prevented to end up with tons of different annotations that could conflict with each other. If using the PhpStorm with the Annotations plugin the options available are all being autocompleted too btw. I'll leave this open for now to discuss possible new annotations that can currently not be done. |
The idea, if that wasn't clear, is to allow others to write annotations for route settings outside of this module.
--Yes, this is what I am doing. It is great :)-- |
The annotations also have to be loaded manually because I couldn't not find a way of doing this in Drupal. Maybe a few other annotations can be created but I think most of it is covered by this. |
Yes, I noticed I needed to add some code to This is called from RouteEventSubscriber and from ControllerEventSubscriber. I am going to push a preview branch or PR soon-ish. |
I notice that those extra annotations only work on methods, not on the class itself. |
…edRouteControllerLoader::configureRoute().
…ionLoader::load().
The actual test cases have yet to be written.
…style parameter types.
…teParameters annotation.
I am working with the new annotations, and I think they are fun. I also created a custom module with more annotation classes |
I was looking at AnnotatedRouteControllerLoader::configureRoute().
Currently this supports a limited and hardcoded selection of annotation classes.
What about a new interface for generic route config annotations, like this:
Then in AnnotatedRouteControllerLoader::configureRoute() we would add this:
As a (controversial) use case, currently I am thinking of this: #3
E.g. a
@MenuLink(..)
annotation, which would set an option in the route, which later can be read by a menu link plugin derivative.Maybe there are less controversial use cases.
E.g. shortcuts for
@Security
: Instead of@Security(access=true)
, one could then write@AccessPublic
.Or instead of
@Security(role="admin")
, write@Role("admin")
Or maybe a
@RouteTitle("Hello")
or a generic@Option(_title = "Hello")
, instead of@Route("/path/to/hello", options = {"title" = "Hello"})
Ok, I am not sure yet if my examples are really worthwhile, but I do think it would open some interesting possibilities.
Btw, I prefer longer identifiers like
@RouteTitle
over just@Title
, this reduces the ambiguity on IDE autocomplete.The text was updated successfully, but these errors were encountered: