Skip to content

Commit 0f370c0

Browse files
committed
Refactor Phalcon\Cli\Console class
1 parent 0043c7e commit 0f370c0

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed

phalcon/Cli/Console.zep

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,30 +36,26 @@ class Console extends AbstractApplication
3636
*/
3737
public function handle(array arguments = null)
3838
{
39-
var className, container, dispatcher, eventsManager, module, moduleName,
39+
var className, dispatcher, module, moduleName,
4040
moduleObject, modules, path, router, task;
4141

42-
let container = this->container;
43-
44-
if container === null {
42+
if this->container === null {
4543
throw new Exception(
4644
"A dependency injection container is required to access internal services"
4745
);
4846
}
4947

50-
let eventsManager = <ManagerInterface> this->eventsManager;
51-
5248
/**
5349
* Call boot event, this allows the developer to perform initialization
5450
* actions
5551
*/
56-
if eventsManager !== null {
57-
if eventsManager->fire("console:boot", this) === false {
52+
if this->eventsManager !== null {
53+
if this->eventsManager->fire("console:boot", this) === false {
5854
return false;
5955
}
6056
}
6157

62-
let router = <Router> container->getShared("router");
58+
let router = <Router> this->container->getShared("router");
6359

6460
if !count(arguments) && this->arguments {
6561
router->handle(this->arguments);
@@ -77,8 +73,8 @@ class Console extends AbstractApplication
7773
}
7874

7975
if moduleName {
80-
if typeof eventsManager == "object" {
81-
if eventsManager->fire("console:beforeStartModule", this, moduleName) === false {
76+
if this->eventsManager !== null {
77+
if this->eventsManager->fire("console:beforeStartModule", this, moduleName) === false {
8278
return false;
8379
}
8480
}
@@ -93,7 +89,7 @@ class Console extends AbstractApplication
9389

9490
let module = modules[moduleName];
9591

96-
if unlikely typeof module != "array" {
92+
if unlikely typeof module !== "array" {
9793
throw new Exception("Invalid module definition path");
9894
}
9995

@@ -113,37 +109,37 @@ class Console extends AbstractApplication
113109
}
114110
}
115111

116-
let moduleObject = container->get(className);
112+
let moduleObject = this->container->get(className);
117113

118-
moduleObject->registerAutoloaders(container);
119-
moduleObject->registerServices(container);
114+
moduleObject->registerAutoloaders(this->container);
115+
moduleObject->registerServices(this->container);
120116

121-
if typeof eventsManager == "object" {
122-
if eventsManager->fire("console:afterStartModule", this, moduleObject) === false {
117+
if this->eventsManager !== null {
118+
if this->eventsManager->fire("console:afterStartModule", this, moduleObject) === false {
123119
return false;
124120
}
125121
}
126122

127123
}
128124

129-
let dispatcher = <Dispatcher> container->getShared("dispatcher");
125+
let dispatcher = <Dispatcher> this->container->getShared("dispatcher");
130126

131127
dispatcher->setModuleName(router->getModuleName());
132128
dispatcher->setTaskName(router->getTaskName());
133129
dispatcher->setActionName(router->getActionName());
134130
dispatcher->setParams(router->getParams());
135131
dispatcher->setOptions(this->options);
136132

137-
if typeof eventsManager == "object" {
138-
if eventsManager->fire("console:beforeHandleTask", this, dispatcher) === false {
133+
if this->eventsManager !== null {
134+
if this->eventsManager->fire("console:beforeHandleTask", this, dispatcher) === false {
139135
return false;
140136
}
141137
}
142138

143139
let task = dispatcher->dispatch();
144140

145-
if typeof eventsManager == "object" {
146-
eventsManager->fire("console:afterHandleTask", this, task);
141+
if this->eventsManager !== null {
142+
this->eventsManager->fire("console:afterHandleTask", this, task);
147143
}
148144

149145
return task;

0 commit comments

Comments
 (0)