/**
* Checks cache for cached pages. If found the original response is served,
* otherwise normal processing will occur.
*
* Observes: controller_action_predispatch
*
* @param $observer
* @return void
*/
public function checkAndServeCachedPage(Varien_Event_Observer $observer)
{
/**
* @var $controllerAction Mage_Core_Controller_Varien_Action
* @var $engine Brim_PageCache_Model_Engine
*/
/*
* controller_action_predispatch occurs before the autoloader sets the scope for the compiler. When the compiler
* is enabled there is the possibility of creating a redeclare class fatal error if we need any class that is
* included in the compilers current scope file. ESP. an issue with the checkout scope. Registering the scope
* here prevents the fatal error from occurring.
*/
if (defined('COMPILER_INCLUDE_PATH')) {
$controllerAction = $observer->getControllerAction();
Varien_Autoload::registerScope($controllerAction->getRequest()->getRouteName());
}
$engine = Mage::getSingleton('brim_pagecache/engine');
if (!$engine->isEnabled()) {
return;
}
$engine->servePage($this);
}