Skip to content

Instantly share code, notes, and snippets.

@zircote
Created February 13, 2012 21:32
Show Gist options
  • Select an option

  • Save zircote/1820659 to your computer and use it in GitHub Desktop.

Select an option

Save zircote/1820659 to your computer and use it in GitHub Desktop.
Just an example of what could not necessarily what should be....
<?php
/**
*
*
* @author Robert Allen <zircote@zircote.com>
* @package ZfApiVersion
* @subpackage
*
*
*/
class Application_Plugin_Version extends Zend_Controller_Plugin_Abstract
{
public function preDispatch($request)
{
/* @var $bootstrap Zend_Application_Bootstrap_Bootstrap */
if($request->getModuleName() == 'default' && ! $request->getControllerName() == 'error' && ($request->getControllerName() != 'index')){
$bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap');
$defaultVersion = $bootstrap->getOption('defaultVersion');
$apiVersion = (string) $request->getParam('version', $defaultVersion);
$request->setModuleName($apiVersion)
->setControllerName($request->getControllerName())
->setActionName($request->getActionName())
->setDispatched(false);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment