I'm using CakePHP 2.3.0 and I need to be able to use an object (Logger) everywhere in my applications (from controllers and models).
This object is created in the AppController like this :
<?php
App::uses('Controller', 'Controller');
App::uses('Logger', 'Lib');
class AppController extends Controller {
public function beforeFilter(){
$this->Logger = new Logger(APP.'webroot/logs');
}
}
?>
This works fine for controllers, I can use this object from every controller of the application, this way : $this->Logger->...
But obviously, it doesn't work from a model (because models don't extends AppController).
So I need :
- to know how to access a controller attribute (Logger) from a model
- or another way to achieve this (creating a global object accessible everywhere), not using
AppController->beforeFilter()
Thanks