Open lanlin opened 6 years ago
There are no modules system in cli mode.
You would need to write your own dispatcher for multi module cli.
You can see this - https://forum.phalconphp.com/discussion/7283/multiple-module-cli
@Jurigag I did that from the beginning.
I didn't attach any event in cli mode before. After attach events, i find i can't get module name from callback.
Like above, the $arguments passed to handle() contains a module name.
In mvc application's handle() method, line 266 dispatcher->setModuleName
been called, so module name been setted correct, but it's not been setted yet in console's handle() method.
I think that's why i can't get the module name from event callback.
The getTaskName & getActionName methods both can return a valid value.
I have another way to get the module name, from the router $router->getModuleName
.
I just wander could it be a issue?
It's not set because Dispatcher cli doesn't use modules at all. It's not an issue. Just dispatcher cli/router doesn't support modules.
@Jurigag thanks for your help.
Could it be supported in next version?
I think the peoples who choosen phalcon that means they should be have a little complex project like me, so both cli and mvc all need support multiple modules.
Closing in favor of phalcon/cphalcon#13855. Will revisit if the community votes for it, or in later versions.
phalcon: 3.2.4
description
My project has multiple modules for both mvc application & cli application.
There's many events attached in my project, like 'dispatch:beforeDispatchLoop'.
When this event triggered, from the "getModuleName" method of \Phalcon\Cli\Dispatcher can't get the module name, but \Phalcon\Mvc\Dispatcher did.
The source code of mvc application has called the "setModuleName" method when handle a request,
but the cli console hasn't.
So in cli mode, how to get the module name from the callback function of dispatch event?