-
Notifications
You must be signed in to change notification settings - Fork 91
Conversation
ooooh, sorry for making a pull request straight on the development branche :S |
You can push up another branch, then edit the PR |
nevermind, I thought PR's had to be made to a specific branch, but that is develop, so no problems :D |
@Ocramius I can't seem to get the testcase to work, I 'm probably just missing something trivial. But what do you think of the idea to allow skipping config for classes that are autoloadable? |
@chris-kruining your test asserts that the result is empty when it is not:
Also, code coverage decreased |
src/DispatchListener.php
Outdated
@@ -86,6 +86,12 @@ public function onDispatch(MvcEvent $e) | |||
$events = $application->getEventManager(); | |||
$controllerManager = $this->controllerManager; | |||
|
|||
if (class_exists($controllerName) && ! $controllerManager->has($controllerName)) | |||
{ |
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.
please follow psr-2 http://www.php-fig.org/psr/psr-2/#51-if-elseif-else
👎 |
👎 |
Right! zend-mvc/src/Controller/ControllerManager.php Lines 25 to 32 in 4c4a3a9
|
@Xerkus @thomasvargiu @froschdesign okay I can not and will not argue the validity of your arguments, but I think you can agree with me that having to register each and every single controller(in my case a lot, near 50-70 I believe) It is a giant hassle having to do all that extra typing when adding a new controller or refactoring stuff. for example I added a new module which needed a controller or 10 that I added sequentially over a period of a week or two, and All I do is add a line of code |
If your problem is typing, then why would you change the ControllerManager? 😉 In the past we had a tool for this: ZFTool The same for expressive: zend-expressive-tooling |
If the security concern doesn't directly affect you, an abstract factory is
more than sufficient 👍
…On 8 Sep 2017 10:44, "Chris Kruining" ***@***.***> wrote:
@Xerkus <https://github.com/xerkus> @thomasvargiu
<https://github.com/thomasvargiu> @froschdesign
<https://github.com/froschdesign> okay I can not and will not argue the
validity of your arguments, but I think you can agree with me that having
to register each and every single controller(in my case a lot, near 50-70 I
believe) It is a giant hassle having to do all that extra typing when
adding a new controller or refactoring stuff. for example I added a new
module which needed a controller or 10 that I added sequentially over a
period of a week or two, and All I do is add a line of code FQCN::class
=> \Zend\ServiceManager\Factory\InvokableFactory::class. So can we think
of a way to create a way to validate a class to be a controller without
having to register each and every single class in the config? I can imagine
some things, like detecting if the class trying to be invoked as a
controller implements an interface somewhere in its inheritance chain. Or
maybe add some config where I can define a pattern that will be able to
match a path where controller can be found. I hope we can figure out a
method together :D
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#252 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAJakE1_h5j7hs_SbpPZ2v-ieMhG_Cakks5sgP5TgaJpZM4Ovjvp>
.
|
@chris-kruining service locator is not allowed into my controllers, so I not only add config entries, i am actually creating factories. Service locator is a problem for testability, especially in the long run. During development when you have to create, remove and rename controllers quickly, reflection based LazyControllerAbstractFactory is what you need. Just replace it with actual factory when feature stabilizes enough to be merged. I am going to close this pull request now. |
I have a small issue with having to register controllers in my config while the are perfectly auto loadable via psr-4. some extensive googling didn't yield any results so I wrote a small hack. Of which I have to say: No idea what the performance impact is or if the testcase even remotely works.
So to finalize, is this a valid hack/implementation of dispatching to psr-4 autoloadable classes? if so do you guys want to implement it, or did I totally miss an option/setting/config that allows for autoloading(without having to config it as invokable)?