All pastes #583156 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-06-22 07:31 UTC
rendered paste body
<?php
/**
 * AdaptableCore
 * 
 * @category	AdaptableCore
 * @package 	AdaptableCore
 * 
 * @copyright 	Copyright (c) 2007 Cameron Cox, AdaptableCode <http://adaptablecode.com>
 * @license		http://adaptablecode.com/projects/ac/license
 * @version		$Id: $
 */


/**
 * AdaptableCore
 * 
 * @category	AdaptableCore
 * @package 	AdaptableCore
 * 
 * @copyright 	Copyright (c) 2007 Cameron Cox, AdaptableCode <http://adaptablecode.com>
 * @license		http://adaptablecode.com/projects/ac/license
 * @version		$Id: $
 */class AdaptableCore_Boostrapper extends Zend_Controller_Front 
{
    /**
     * Singleton instance
     *
     * Marked only as protected to allow extension of the class. To extend, 
     * simply override {@link getInstance()}.
     * 
     * @var Zend_Controller_Front
     */
	protected static $_instance;
	
	
	/**
	 * Singleton Instance
	 *
	 * @return	AdaptbleCore_Bootstrapper
	 */
	public static function getInstance()
	{
		if (!self::$_instance instanceof AdaptableCore_Bootstrapper)
		{
			self::$_instance = new AdaptableCore_Boostrapper();
		}
		
		return self::$_instance;
	}
	
	
	/**
	 * Bootstrap the application 
	 *
	 * @param	array|string	$appDirectory
	 * @param	array|string	$apps
	 */
	public static function bootstrap($appDirectory, $modules)
	{
		// load the application modules
		foreach ((array) $modules as $module)
		{
			self::getInstance()->addControllerDirectory($appDirectory . DIRECTORY_SEPARATOR . $module, $module);
		}
		
		// modify the ViewRenderer Helper	
		Zend_Controller_Action_HelperBroker::getExistingHelper('ViewRenderer')->setViewBasePathSpec(':moduleDir/:module')->setViewSuffix('html');
		
		// load custom routes
		$routes = Zend_Loader::loadFile('routes.php');
		if (sizeof($routes) !== 0)
		{
			$router = self::getInstance()->getRouter();
			$router->addRoutes($routes);
		}
	}
}