/** * HTML renderer decorator * * @param SGL2_Response $data * @param string $templateEngine */ public function __construct($response, $templateEngine = null) { $registry = SGL2_Registry::getInstance(); // prepare renderer class if (is_null($templateEngine)) { $templateEngine = $registry->getConfig()->site->templateEngine; } $templateEngine = ucfirst($templateEngine); $rendererClass = 'SGL2_View_Renderer_Html_' . $templateEngine; parent::__construct($response, new $rendererClass()); }
public function testAppContext() { $config = new Zend_Config_Ini(SGL2_PATH . '/tests/config.ini', 'staging'); $registry = SGL2_Registry::createInstance($config); $registry2 = SGL2_Registry::getInstance(); $this->assertThat($registry, $this->identicalTo($registry2)); $this->assertTrue(SGL2_Registry::hasInstance()); $registry->set('foo', new Foo()); $this->assertSame($registry->get('foo'), $registry2->get('foo')); $this->assertTrue(is_a($registry->get('foo'), 'Foo')); }
public static function createInstance(Zend_Config $config, $name = null, $class = __CLASS__) { if (null === $name) { $name = $config->app->name; } self::$current = $name; self::$instances[$name] = new $class(); if (!self::$instances[$name] instanceof SGL2_Context) { throw new Exception(sprintf('Class "%s" is not of the type SGL2_Context.', $class)); } self::$instances[$name]->init($config); return self::$instances[$name]; }
public function dispatch() { $registry = SGL2_Registry::getInstance(); $request = $registry->getRequest(); $response = $registry->getResponse(); $router = $registry->getRouter(); $ret = false; try { $aRet = $router->route($request->getUri()); $ret = $this->processRequest($registry, $request, $response); } catch (Exception $e) { throw $e; } return $ret; }
public function __construct() { $config = new Zend_Config_Ini(PROJECT_PATH . '/var/config.ini', 'staging'); $registry = SGL2_Registry::createInstance($config); $this->registry = $registry; }
public function __construct(SGL2_Registry $registry) { $this->registry = $registry; $this->dispatcher = $registry->getEventDispatcher(); }