/** * 构造方法 * * @param Monkey\App $app */ public function __construct($app) { $this->app = $app; $config = $app->config()->getComponentConfig('errorReporting', 'default'); $dir = (isset($config['errorTemplate']) and !empty($config['errorTemplate'])) ? $app->DIR . $config['errorTemplate'] : strtr(__DIR__, DIRECTORY_SEPARATOR, '/') . '/errorTemplate'; $this->config = array('error_tpl_403' => $dir . '/403.tpl.php', 'error_tpl_404' => $dir . '/404.tpl.php', 'error_tpl_debug' => $dir . '/debug.tpl.php', 'error_tpl_public' => $dir . '/public.tpl.php'); }
/** * 构造方法 * * @param Monkey\App $app * * @throws \Exception */ public function __construct($app) { if (!extension_loaded('apc')) { throw new \Exception('没有安装APC扩展,请先在php.ini中配置安装APC。'); } $config = $app->config()->getComponentConfig('cache', 'apc'); isset($config['expire']) and $this->expire = $config['expire']; }
/** * 构造方法 * * @param Monkey\App $app */ public function __construct($app) { $this->app = $app; register_shutdown_function(array($this, 'execute'), $this->calledByMe); $config = $app->config()->getComponentConfig('shutdown', 'default'); foreach ($config as $call) { $this->register($call); } }
/** * 构造方法 * * @param Monkey\App $app * * @throws \Exception */ public function __construct($app) { if (!extension_loaded('apc')) { new \Exception('会话出错:没有安装APC扩展。', 2048); } $this->app = $app; $this->config = $app->config()->getComponentConfig('session', 'apc'); $this->start(); }
/** * 构造方法 * * @param Monkey\App $app * * @throws \Exception */ public function __construct($app) { if (!extension_loaded('apc')) { new \Exception('会话出错:没有安装Memcache扩展。', 2048); } $this->app = $app; $this->config = $app->config()->getComponentConfig('session', 'memcache'); $this->handler = new \Memcache(); if (!$this->handler->connect($this->config['host'], $this->config['port'])) { new \Exception('会话出错:Memcache连接失败。', 2048); } $this->start(); }
/** * 构造方法 * * @param Monkey\App $app * * @throws \Exception */ public function __construct($app) { if (!extension_loaded('memcache')) { throw new \Exception('没有安装memcache扩展,请先在php.ini中配置安装memcache。'); } $config = $app->config()->getComponentConfig('cache', 'memcache'); isset($config['expire']) and $this->expire = $config['expire']; $this->compressed = isset($config['compressed']) ? $config['compressed'] : false; $this->connection = new \Memcache(); if (!$this->connection->addserver($config['host'], $config['port'], $config['persistent'])) { throw new \Exception('连接memcache服务器时失败,请确认你的连接参数是否正确。'); } }
/** * @param Monkey\App $app */ public function __construct($app) { $config = $app->config()->getComponentConfig('cache', 'file'); $this->TIME = $app->TIME; $this->expire = $config['expire']; $this->cachePath = dir_format($app->TEMP . ($config['dir'] ? $config['dir'] : '/fileCache')); $this->cacheFile = $config['filename'] ? '/' . $config['filename'] : '/data'; $this->cacheSize = $config['filesize'] ? $config['filesize'] : '15M'; $this->dataOnCheck = $config['check'] ? $config['check'] : false; //是否验证数据 if (!dir_check($this->cachePath)) { $this->error('缓存目录校验失败。'); } $this->workat($this->cachePath . $this->cacheFile); }
/** * @param Monkey\App $app * * @throws \Exception */ public function __construct($app) { //效验pdo组件是否存在 if (!extension_loaded('pdo')) { throw new \Exception('没有安装pdo驱动扩展,请先在php.ini中配置安装pdo!', 1024); } //载入数据组件配置 $this->app = $app; $config = $app->config()->getComponentConfig('database', 'default'); $this->config = $config; isset($config['pool']) and $this->pool = $config['pool']; isset($config['default_connection']) and $this->default = $config['default_connection']; //设置默认连接 if (!$this->default || !isset($this->pool[$this->default])) { reset($this->pool); $this->default = key($this->pool); } }
/** * 构造方法 * * @param Monkey\App $app */ public function __construct($app) { $this->app = $app; $config = $app->config()->getComponentConfig('router', 'default'); $this->config = $config; $this->indexRoot = $app->INDEX_ROOT_URL; $this->pattern = new Pattern($app, $config); $this->loadPath(); $this->requestMethod = $app->request()->getMethod(); $match = $this->pattern->matchPath($this->requestMethod, $this->path); $this->params = isset($match['params']) ? $match['params'] : null; $route = array(); if (isset($match['router_name'])) { $config['router_class_auto_prefix'] and $match['router_name'] = '\\' . $this->app->NAME . '\\Controller\\' . $match['router_name']; list($route['controller'], $route['action']) = explode(':', $match['router_name'], 2); } $this->route = $route; $this->hook = new Hook($app); }
/** * 构造方法 * * @param Monkey\App $app */ public function __construct($app) { $this->app = $app; $this->config = $app->config()->getComponentConfig('view', 'default'); $this->themeUrlBase = $app->FRONT_ROOT_URL . $this->config['theme_url_base']; $this->themeDirName = $this->config['theme_dir']; $this->template = new Template($app, $this->config); }