php - Cakephp call an component method inside a helper -
i use cakephp 2.1 , need call component method witch resides in plugin, view helper:
the component here:
/app/plugin/abc/controller/component/abccomponent.php
the helper here:
/app/view/helper/simplehelper.php
i tried inside helper:
app::import('component', 'abc.abc'); $this->abc = new abc(); or $this->abc = new abccomponent;
or
$this->abc = $this->components->load('abc.abc');
inside controllers component works no problem. know isn't recommended (mvc design etc.) if don't use way need duplicate lot of code. need make like:
myhelper extends helper{ $simplevar = component->get_data(); }
i use cakephp 2.4
this how call component helper:
app::uses('aclcomponent', 'controller/component'); class myhelper extends apphelper { public function myfunction() { $collection = new componentcollection(); $acl = new aclcomponent($collection); // here can use aclcomponent in $acl if ($acl->check($aro, $aco) { // ... } } }
Comments
Post a Comment