Create vendor class objects in components of cakephp
In cakephp, I want to import a vendor php file which contains different classes eg(class A class B, class C, each having __construct() method), in my component.I want to create objects of each class in the comp开发者_高级运维onent and call respective class function in my controller.
What is the correct process to implement it.
Try this
component:
class LibraryComponent extends Object {
public function classA($params) {
App::import('Vendor', 'library', array('file' => 'classA.php'));
$class = new classA($params);
return $class;
}
}
controller:
$myClass = $this->Library->classA($params);
精彩评论