-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"$this->eventsManager" return null #14269
Comments
In which case we will need to add the |
Sorry I do not understand the issue. The code is identical to v3 meaning What are you trying to do? |
Never mind @CameronHall explained it |
|
@zuozhehao can you please provide a code sample? |
class BaseController extends \Phalcon\Mvc\Controller
{
public function afterExecuteRoute($dispatcher)
{
$this->eventsManager->fire('someEvent' ,$this);
}
} |
@zuozhehao how do you populate your Di? With |
@CameronHall yes, |
Thanks @zuozhehao I'll take a look. |
@zuozhehao I've tried reproducing this but haven't be able too. After rereading through all the code, there's no reason why this shouldn't work, the only reason it wouldn't is if the the eventsManager isn't in your DI. One thing I have noticed specifically is that the cphalcon/phalcon/Di/Injectable.zep Lines 88 to 93 in 4173bca
|
@CameronHall <?php
class BaseController {
/**
* Events Manager
*
* @var \Phalcon\Events\ManagerInterface
*/
protected $eventsManager;
/**
* Magic method __get
*/
public function __get($propertyName) {
var_dump($propertyName);
}
/**
* Sets the event manager
*/
public function setEventsManager($eventsManager)
{
$this->eventsManager = $eventsManager;
}
}
class IndexController extends BaseController {
public function indexAction() {
var_dump($this->eventsManager);
}
}
(new IndexController)->indexAction(); |
@sergeyklay If you could check why this pull is failing and working in nanobox it would be great. |
This has been addressed in #14445 |
phalcon 4
I found that "protected event manager" would affect the magic method _get to get "eventsManager" when I did not use "setEventsManager"
cphalcon/phalcon/Di/Injectable.zep
Lines 60 to 82 in 4173bca
The text was updated successfully, but these errors were encountered: