I’m using the great Facebook plugin for cakephp 1.3 by http://www.webtechnick.com. This is what I have at the moment:
class UsersController extends AppController {
var $name = 'Users';
var $components = array('Facebook.Connect');
function beforeFilter {
$this->set('facebookUser', $this->Connect->user());
}
}
But I want to load the Facebook.Connect component conditionally, and use it in the controller – something like this in sudocode…
if ($thisIsTrue) {
Load_the_component_and_make_it_ready_for_use;
$this->set('facebookUser', $this->Connect->user());
}
How should I do this?
Since the Component is initialized while loading with the controller I wouldn’t recommend loading it later on.
Like maggie commented you could load the component ( http://book.cakephp.org/view/939/Loading-Components ) but then you’d have to call startup and initialize yourself and attach the object to your controller.
All in all it might be easier to just make the $this->set… conditional and let the component load every time.