Eu estou usando o Cakephp 2.3.0, carregando o seguinte componente.
class BreadCrumbsComponent extends Component {
public $components = array();
public $controller = null;
public function initialize($controller) {
}
public function startup($controller) {
$this->controller = $controller;
}
public function beforeRender($controller) {
}
public function shutDown($controller) {
}
public function beforeRedirect($controller, $url, $status = null, $exit = true) {
}
public function handle($controllerName = NULL, $actionName = NULL) {
pr($this->controller->modelClass);
}
}
Obtém erro após erro
Trying to get property of non-object [APPControllerComponentBreadCrumbsComponent.php, line 38]
Eu não consigo acessar o $ this-> controller lá. Qualquer razão? Como eu faço funcionar?
Respostas:
4 para resposta № 1Ler Aqui comece método é chamado após o controlador então precisa inicializar o controlador em inicializar método como abaixo,
public function initialize(&$controller, $settings = array()) {
$this->controller = $controller;
}