Skip to content

Instantly share code, notes, and snippets.

@bjlbernal
bjlbernal / 1. Use Controller::afterFilter()
Last active March 21, 2016 16:47
Cake Events (2.* at least) do not have to block controller logic, and you don't have to have a separate queuing system to process the events. Simply have them handled in the Controller::afterFilter() method. Per cake docs, the Controller::afterFilter() method is called "after the rendering" of the view is complete. This may be a more fragile way…
<?php
class AppController extends Controller
{
...
public $afterFilterEvents = array();
public function afterFilter() {
parent:afterFilter();