php - cakephp using components as controller methods -


i'm trying find best, cleanest way of initialising method within controller. want record 'likes', 'posts' etc 'actions' when happen.

actions working fine on submission, not outside it's own controller.

in likescontroller, want able go:

$this->action->add($fields); 

but doesn't work, if $this->loadmodel('action'); beforehand. after reading around seems 'components' way go...

so wondering how achieve using components. i've got far in likescontroller:

public $components = array(     'requesthandler','helper',         'action' => array('controller'=>'actions', 'action'=>'add'), ); 

but still no joy when try call $this->action->add.

what best method of doing this, , how can set component class work though action controller, , able use methods?

if can award rep best answer will..! many in advance.

a component isn't same model. if want things way, you'll have turn action model component.

the component go controller/component/actioncomponent.php, , can included controllers this:

public $components = array(..., 'action'); 

the logic in component can similar in model, there differences. example, still have action model, , component can use crud , other stuff. you'll have use classregistry::init() load model component though.

i can't explain how want, 1 reason being don't know precisely enough want. however, i've written own component before , can use reference if - it's possibly more complicated yours can see how write methods it.

custom acl component

in example, once it's included in controller, can call $this->customacl->check() anywhere like.

i hope enough started @ least.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -