'Set' in Components of Cake PHP

cakephp, cakephp-1.3

Solution

function startup($controller) { $this->controller = $controller }
function something() {
    $this->controller->set('User',$user);
}

Cake passes the Controller reference to the startup function of a Component. You need to keep a reference in your component to use later in custom functions.

See here http://book.cakephp.org/1.3/en/view/996/Creating-Components#MVC-Class-Access-Within-Components-998

Problem

How to use Set function inside components in cake php ? ``` class TestComponent extends Object { //etc $this->set('User', $user); } ``` I am getting an error ``` Fatal error: Call to undefined method TestComponent::set() ``` How this can be corrected ?

Original source