protected function _initStoreRoutes() { $request = new Zend_Controller_Request_Http(); $path = explode('/', trim($request->getPathInfo(), '/')); $requestedPath = array_shift($path); $requestedHost = $request->getHttpHost(); if ($store = Cosmos_Api::get()->cosmos->getStoreByHostPath($requestedHost, $requestedPath)) { $this->bootstrap('session'); Zend_Registry::set('csession', new Zend_Session_Namespace("cosmos_{$store['group_id']}")); Zend_Registry::get('log')->info($store); if ($store['path']) { $this->bootstrap('frontcontroller'); $front = Zend_Controller_Front::getInstance(); $request = $front->getRequest(); $dispatcher = $front->getDispatcher(); $defaultRoute = new Zend_Controller_Router_Route_Module(array(), $dispatcher, $request); $front->getRouter()->removeDefaultRoutes(); $defaults = array('path' => $store['path'], 'module' => $dispatcher->getDefaultModule()); $pathRoute = new Zend_Controller_Router_Route(':path', $defaults); Zend_Registry::set('cosmosRoute', $pathRoute); // This is to catch empty requests because for some reason 'default' doesn't. $front->getRouter()->addRoute('default-empty', $pathRoute); $front->getRouter()->addRoute('default', $pathRoute->chain($defaultRoute)); Zend_Registry::set('mode', 'path'); } else { Zend_Registry::set('mode', 'host'); } } else { die('fail'); // no matching store? } Cosmos_Addon::getInstance($store['addons']); }
public function indexAction() { Cosmos_Profiler::start('calc.multiply'); // This is not typical because a core action would not be using add-on methods. $this->view->result = Cosmos_Api::get()->calc->divide(10, 2); $this->view->service_plugin_result = Cosmos_Api::get()->sample->add(5, 5); Cosmos_Profiler::stop('calc.multiply'); }
public function preDispatch(Zend_Controller_Request_Abstract $request) { // 404, try a custom url... if (!Zend_Controller_Front::getInstance()->getDispatcher()->isDispatchable($request)) { $temp = $request->getRequestUri(); $checker = Cosmos_Api::get()->url->check($temp); if ($checker) { // @todo: this should allow for regular redirects, or dispatching a different controller/action/module without actually redirecting. Zend_Controller_Action_HelperBroker::getStaticHelper('Redirector')->gotoSimple($checker['action'], $checker['controller'], $checker['module']); } } }
public function indexAction() { $this->view->content = Cosmos_Api::get()->content->read(); }
public function updateContentAction() { Cosmos_Api::get()->content->write($_POST['content']); return $this->_helper->redirector('index', 'sample-content', 'backend'); }