Question

I want to log events across multiple controllers and store them in my 'actions' database. I need to have actions as a class/controller because I need to get the ID for that action object after it has saved.

What is the best way of doing this so that I can run a method across any controllers to add a new action into the database?

$this->Action->log($array);

Many thanks

Was it helpful?

Solution

You should use a Component for that. Components are objects that can be used across any controller (as long as you include it in the controller's $components property, or in that of the AppController).

For example, if you have any experience with Auth in Cake, that's a Component, and its methods can be called from any controller.

More info about components here: http://book.cakephp.org/2.0/en/controllers/components.html

If you need more help, feel free to try and write a component yourself and come back with any problems you might have.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top