/** * 应用程序加载前实例化 * 如果需要对本方法进行扩展,可以重载本方法 * @param array $plugins 要在本执行里执行的插件组 * @return self */ protected function execute($plugins) { if (!empty($plugins)) { $this->setPlugins($plugins); } $result = null; $plugins = $this->getPlugins(); if (!empty($plugins) && is_array($plugins)) { $result = null; foreach ($plugins as $plugin) { // 加工厂,把前面一个插件运行的结果传递给后面 $result = $plugin->run($result); // 把前面的结果保存在运行对象里供后续使用 if ($result instanceof Leb_Plugin_Abstract) { $this->setRunner($result->getAlias(), $result); } } } return parent::execute($result); }
/** * 设置本对象需要的请求对象 * * @param Leb_Request $plugins */ public function execute($plugins) { $this->_initConfig(); // 获得传递过来的request对象 $this->setRequest($plugins); // 解析网址以生成相应的参数对象 if ($this->getEnv('rewrite')) { $this->matchRouter(); $this->_appName = $this->_getApp(); $this->_controllerName = $this->_getController(); $this->_actionName = $this->_getAction(); //$this->_querys = $this->_getQuerys(); } return parent::execute($plugins); }
/** * 设置本对象需要的请求对象 * * @param Leb_Request $plugins */ public function execute($plugins) { $this->_initConfig(); // 获得传递过来的request对象 $this->setRequest($plugins); // 解析网址以生成相应的参数对象 $this->_querys = $this->_matches = $this->_getQuerys(); if ($this->_matches) { unset($this->_matches[0]); $this->_matches['app'] = $this->_matches['controller'] = $this->_matches['action'] = ''; foreach ($this->_matches as $key => $value) { $pre = strpos($value, '--'); $pos = strpos($value, '='); if (false === $pre && false === $pos) { if (!$this->_matches['app']) { $this->_matches['app'] = $value; } elseif (!$this->_matches['controller']) { $this->_matches['controller'] = $value; } elseif (!$this->_matches['action']) { $this->_matches['action'] = $value; } } } } $this->_appName = $this->_getApp(); $this->_controllerName = $this->_getController(); $this->_actionName = $this->_getAction(); return parent::execute($plugins); }