Hi. I'm trying to call a component function which accesses $this-
>controller on the controller's beforeFilter .. and I get an error
mentioning $this->controller is not an object. It works ok when I call
the same function on index. Here's some example code, is there any
workaround ? Using 1.2 beta.
class SomeController extends AppController{
var $components = array('SomeComponent');
var $mystuff = null;
function index() {
echo "on index ".$this->SomeComponent->getMyStuff();
}
function beforeFilter() {
$this->mystuff = $this->SomeComponent->getMyStuff();
}
}
class SomeComponent extends Component {
function initialize(&$controller) {
$this->controller = $controller;
}
function getMyStuff() {
if($this->controller->user) {
return "has stuff";
}
else {
return false;
}
}
}
Thanks in advance
gui
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---