Protecting Assets with Zend Controller Plugins

October 30th, 2009

I 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.

 

discuss video in the forum

6 Responses to “Protecting Assets with Zend Controller Plugins”

  1. developtus says:

    +10!!! awesome! very good screencasts!! thx

  2. Master B. says:

    Absolutly Great!

  3. Claudio S. says:

    Thanks!! great screencasts

  4. Schell says:

    AssetGrabber – genius!

  5. Rick says:

    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.

  6. Rick says:

    Completly sorry! Posted on the wrong cast!!

Leave a Reply

Desktop RSS feed iPhone + iPod