This repository was archived by the owner on Nov 27, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Integrate DunglasActionBundle #960
Closed
Closed
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,3 +66,15 @@ swiftmailer: | |
username: "%mailer_user%" | ||
password: "%mailer_password%" | ||
spool: { type: memory } | ||
|
||
# Can be changed directly in the bundle is we found an agreement | ||
dunglas_action: | ||
autodiscover: | ||
enabled: true | ||
directories: | ||
action: [ ] | ||
console: [ Command ] | ||
directories: # List of directories relative to the kernel root directory containing classes to auto-register. | ||
action: [ '../src/AppBundle/Controller' ] # Still an autowiring_type definition to add in Symfony to avoid this | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. empty lines should be removed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
app: | ||
resource: "@AppBundle/Controller/" | ||
type: annotation | ||
type: action-annotation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be great to use
symfony/finder
in your bundle to be able to use something like../src/*/Controller
instead.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should default to something like that, to avoid registering controllers and services from third-party bundles. I'll do it. That way, we can easily map
Controller
andCommand
without any risk to interfere with commands and controllers defined by public bundles.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's worth any extra overhead, and there's no precedent for it in other service imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't expect the configuration to work like this. It had never occurred to me to do any sort of autowiring across all bundles - I initially don't like that idea, and it complicates the configuration (I had to research what the difference was between the
autodiscover
anddirectories
keys).Also:
action
andconsole
keys significant? I think they are. If so, it's weird to me to also allow other keys - likefoo
(used in the bundle README). I understand that this is to allow other directories to be autowired, but I don't like that sometimes the keys are special, and sometimes not. It also means we can't catch typos.Still an autowiring_type definition to add in Symfony to avoid this
- whatdoes this refer to?
action-annotation
route type altogether? In other words, extend@Route
to use a service definition for the controller if one exists? I ask because it feels like there are two ways to auto-register a controller as a service: either by using some config inconfig.yml
or by using theaction-annotation
. The line between what each does is blurry. I think extending@Route
may be a non-trivial task, but it makes a lot more sense to me: it's in the spirit of autowiring where we (in this case the@Route
system) effectively "asks" the container for the service for an instance and it returns it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw, I am cautiously interested about all of this - my criticisms are because if it we were to go to the trouble of supporting this, let's do it really well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, I see now that
action-annotation
does nothing more than auto-set the_controller
to theaction.*
pattern. That feels weak.A more generic solution where
@Route
just works with service controllers looks even more appealing. In fact, if we could pull it off, then it could work in YAML too using the existing syntax - e.g.If that class were represented as a service, it could/would use that service automatically. Otherwise, it would create a new instance like now.
I'm assuming you've thought about this - it would require a service that contained a run-time class => service id map for resolution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with most of your arguments and I've made changes accordingly in the bundle:
Controller
andCommand
are now the default config (Support traditional Symfony conventions dunglas/DunglasActionBundle#26) - it allows to be as close as possible to current Symfony conventionsaction-annotation
routing type is being removed, the usualannotation
will work (Support standard annotation type in prefix dunglas/DunglasActionBundle#29)I'm not confortable with adding some magic in the router to guess the service corresponding to the type. The router supports services for a while using the 'service_name:method' syntax for while. It's what use the bundle. I prefer to keep it as is it will be easier to debug.
For the missing autowiring_type, it's for
KernelInterface
but it's not related anymore to this PR.