In my CakePHP 2 application I have such vendor. I need to create an instance of this vendor class inside my controller class. So I will use that instance inside my controller's different functions.
App::import('Vendor', 'fancyVendor', array('file' => 'fancyVendor.php'));
class MyController extends AppController {
public $fancyVendor;
function beforeFilter() {
$fancyVendor = new fancyVendor();
$fancyVendor->setValue("12");
}
function showMe() {
echo $fancyVendor->getValue();
}
}
Inside my showMe function, I can't get the value that I set inside my beforeFilter function. Is there a proper way to instantiate it?