I'm trying to find the best, cleanest way of initialising a method from within another controller. I basically want to record 'likes', 'posts' etc as 'actions' when they happen.
Actions are working fine on submission, but not from outside it's own controller.
In the LikesController, I want to be able to simply go:
$this->Action->add($fields);
But this doesn't work, even if I do $this->loadModel('Action');
beforehand. After reading around it seems that 'components' is the way to go...
So I was wondering how I would achieve this using components. I've got this so far in my LikesController:
public $components = array(
'RequestHandler','Helper',
'Action' => array('controller'=>'actions', 'action'=>'add'),
);
But still no joy when I try to call $this->Action->add
.
What is the best method of doing this, and how can I set up the component class to work as though it is the Action controller, and able to use its methods?
If I can award REP to the best answer then I will..! Many thanks in advance.