/** * Return the route for the request module/controller/action. This method can be used to get the rewritten * URL for an action to set anchor tag accordingly. * * @param (string) $info String containing module conroller and action <code>module/controller/action</code> */ public function getRoute($info) { if (null != $info) { return Registry::getInstance()->config->systemConfig->findRoute($info); } return false; }
/** * * Initiate the Zend DB Adapter and Return */ public static function getAdapterInstance() { $config = Registry::getInstance()->config; if (self::$adapterInstance == null) { self::$adapterInstance = new Adapter($configArray = array('driver' => $config->driver, 'database' => $config->database, 'username' => $config->username, 'password' => $config->password)); } return self::$adapterInstance; }
/** * * */ public function __construct() { $this->view = new CoreView(); $this->registry = Registry::getInstance(); $this->request = $this->registry->request; /* Set event object, Event object will be used to attach some data and will be passed to listeners */ $this->event = new Event(); // creat event dispatcher object $this->eventDispatcher = EventDispatcher::getInstance(); // set plugin Manager instance $this->setPluginManager(PluginManager::getInstance()); /* */ $this->setView(); }
/** * Construct module specific configuration file path */ public function constructPath() { $module = $this->getRequest()->getModule(); $path = $this->getRequest()->getBasePath() . DS . 'extension' . DS . 'modules' . DS . $module . DS . strtolower($module) . '.xml'; /// if configuration file does not exists in user space code for this module // load from default path if (!file_exists($path)) { $path = $this->getRequest()->getBasePath() . DS . Registry::getInstance('config')->appDir . DS . 'modules' . DS . $module . DS . strtolower($module) . '.xml'; } return $path; }
/** * Set Plugin Directory Path */ public function __construct() { $this->request = Registry::getInstance('request'); }
/** * Set module path */ public function setModulePath() { $this->modulePath = Registry::getInstance('request')->getBasePath() . DS . 'extension' . DS . 'modules'; return $this; }
/** * Display Formatted Exception Message */ public function renderException($exception) { $config = Registry::getInstance()->config; $appTitle = function () use($config) { if (isset($config->appName)) { return $config->appName; } return; }; $title = $appTitle() . ' Application Error'; $code = $exception->getCode(); $message = $exception->getMessage(); $file = $exception->getFile(); $line = $exception->getLine(); $trace = $exception->getTraceAsString(); $html = sprintf('<h1>%s</h1>', $title); $html .= '<p>The application could not run because of the following error:</p>'; $html .= '<h2>Details</h2>'; $html .= sprintf('<div><strong>Type:</strong> %s</div>', get_class($exception)); if ($code) { $html .= sprintf('<div><strong>Code:</strong> %s</div>', $code); } if ($message) { $html .= sprintf('<div><strong>Message:</strong> %s</div>', $message); } if ($file) { $html .= sprintf('<div><strong>File:</strong> %s</div>', $file); } if ($line) { $html .= sprintf('<div><strong>Line:</strong> %s</div>', $line); } if ($trace) { $html .= '<h2>Trace</h2>'; $html .= sprintf('<pre>%s</pre>', $trace); } echo sprintf("<html><head><title>%s</title><style>body{margin:0;padding:30px;font:12px/1.5 Helvetica,Arial,Verdana,sans-serif;}h1{margin:0;font-size:25px;font-weight:normal;line-height:25px;}strong{display:inline-block;width:65px;}</style></head><body>%s</body></html>", $title, $html); }
/** * Load classes from application directory */ public function loadApp($namespace) { $path = Registry::getInstance('request')->getBasePath() . DS . Application::getInstance()->getAppDir() . DS . $this->path . DS . $this->class . '.php'; if (file_exists($path)) { require_once $path; return; } throw new EasyException('404 Not Found. Could not found "' . $namespace . '"'); }
/** * */ public function getSystemConfig() { return Registry::getInstance()->config->systemConfig; }
/** * initialize required objects */ public function init() { $this->config = Registry::getInstance()->config = ApplicationConfig::getInstance(); $request = Registry::getInstance()->request = new Request(); $this->setAppName($this->config->appName); $this->setRouter(Router::getInstance())->setRequest($request)->setRawRoute()->setDefaultModule('site')->setDefaultController('site')->setDefaultAction('index')->setBasePath(dirname(dirname(dirname(__FILE__))))->setModule()->setController()->setAction(); // load module (modules which are in extension folders ) configuration ModuleManager::getInstance()->loadModuleConfig(); //set application configurations config.ini // Load system configuration system.xml $this->config->setConfigFile($this->getConfigFile())->setSystemConfigFile($this->getSystemConfigFile())->loadConfiguration(); // load the userspace bootstrap class and run init method $initialize = Registry::getInstance()->request->getBasePath() . DS . Registry::getInstance()->config->appDir . DS . 'initializer.php'; if (file_exists($initialize)) { $initializer = new \initializer(); $initializer->init(); } // Module specific configuration file <module>.xml ModuleConfig::getInstance()->loadConfiguration(); // load plugin configurations PluginManager::getInstance()->loadPluginConfig(); // load plugins PluginManager::getInstance()->loadPlugins(); $this->exception = new EasyException(null); return $this; }