开发者

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜