I have some testing and it call controllers like so:
\Phalcon\DI::reset();
\Phalcon\DI::setDefault($this->di);
$dispatcher = new \Phalcon\Mvc\Dispatcher();
$dispatcher->setDI(\Phalcon\DI::getDefault());
$dispatcher->setControllerName('Api\\Controllers\\' . $this->controller);
$dispatcher->setActionName($action);
$dispatcher->setParams([$debug]);
$object = $dispatcher->dispatch();
return call_user_func([$object, $action . 'Action']);
When i calling controller in one test multiple times i got some strange results. In my controller for this test i dump a DI service that handle a parser request:
if ($debug) {
var_dump($this->apiRequest->request);
var_dump($this->di->get('apiRequest'));
exit();
}
In first case i got:
object(stdClass)#368 (3) {
["payment_id"]=>
int(1417693101)
["timestamp"]=>
int(1417693051)
["user_id"]=>
int(4)
}
In second case i got:
object(stdClass)#374 (5) {
["request_id"]=>
int(14224571498071)
["atm"]=>
int(295)
["request_hash"]=>
string(47) "14224571498071:ca3ad13574476de68c4dc2f37c481a63"
["request"]=>
object(stdClass)#375 (4) {
["cash"]=>
array(0) {
}
["payment_id"]=>
int(1417693101)
["timestamp"]=>
int(1417693051)
["user_id"]=>
int(4)
}
["hash"]=>
string(40) "ac4fbc57a94d5687f9c35c2927b78b4b6471b05e"
}
My question - is $this-><di_service_name>
is not shortcut of $this->di->get(<di_service_name>)
?