Protecting Assets with Zend Controller Plugins
October 30th, 2009I had to take a little hiatus the last few weeks, however I’m hoping to get back into a weekly posting schedule.
This video is an introduction in how to effectively use Zend Controller Plugins. The Zend Documentation refers to Zend Controller plugins being part of the Action Stack which is a simple data structure that can be filled with a bunch of plugins which will run in succession.
We’ll create a simple asset protection script using the Zend Framework’s built in Zend Controller Plugin architecture.
Grab a copy of the project or browse the repository.

+10!!! awesome! very good screencasts!! thx
Absolutly Great!
Thanks!! great screencasts
AssetGrabber – genius!
To make it work with Zend_Navigation I used this code:
frontController = Zend_Controller_Front::getInstance();
$router = $this->frontController->getRouter();
$language = $request->getParam(‘language’,”);
if($language !== ‘en’ && $language !== ‘nl’ && $language !== ‘de’ && $language !== ‘fr’ && $language !== ‘be’)
{
$request->setParam(‘language’,'en’);
}
$language = $request->getParam(‘language’);
switch($language)
{
case ‘en’:
$locale = ‘en_US’;
break;
case ‘nl’:
$locale = ‘nl_NL’;
break;
case ‘de’:
$locale = ‘de_DE’;
break;
case ‘fr’:
$locale = ‘fr_FR’;
break;
case ‘be’:
$locale = ‘nl_BE’;
break;
}
$setLanguage = new Zend_Locale();
$setLanguage->setLocale($locale);
Zend_Registry::set(‘Zend_Locale’, $setLanguage);
$translate = new Zend_Translate(‘gettext’, APPLICATION_PATH . ‘/languages/’. $locale . ‘.mo’ , $locale);
Zend_Registry::set(‘Zend_Translate’, $translate);
$router->removeDefaultRoutes();
$router->addRoute(
‘languagecontroller’,
new Zend_Controller_Router_Route(‘/:language/:controller/:action’,
array(‘language’ => $language,
‘controller’ => ‘index’,
‘action’ => ‘index’
)
)
);
}
}
I couldn’t get the parameter in the boostrap, I figured if i set the parameter again in the bootstrap it would be nicer, but getParam(‘language’) keeps returning NULL.
Completly sorry! Posted on the wrong cast!!