CakePHP Globally override class?

2019-07-09 23:53发布

问题:

I reconfigured my cakeEmail class to log to a specific type by rewriting the send method. I would like to use this override globally. My current single file setup uses /Lib/CustomCakeEmail.php with

App:uses('CustomCakeEmail', 'Lib');

CakePhp: Cake Email AfterSend event suggests a method to globally override using AppController but I have been unable to even trigger the debugger in

App::uses('CustomCakeEmail', 'Lib');
class AppController extends Controller {
    public function getEmailInstance($config = null) {
        CakeLog::write('debug', 'appcontroller triggered');
        return new CustomCakeEmail($config);
    }

What is the correct way to implement this global override?

CakePHP Version 2.8.4