/** * 单例模式,获取一个指定的实例 * * // 加载默认实例 * $db = Database::instance(); * * // 指定实例名称和配置 * $db = Database::instance('custom', $config); * * @param string $name 实例名 * @param array $config 配置参数 * @return Connection */ public static function instance($name = null, array $config = null) { if (null === $name) { $name = Db::$default; } if (!isset(Db::$instances[$name])) { // 读取配置 if (null === $config) { $config = (array) Config::load(self::$configFile)->get($name); Base::getLog()->debug(__METHOD__ . ' get default config', ['name' => $name]); } // 合并默认配置 if (isset(self::$defaultConfig[Arr::get($config, 'driver')])) { $config = Arr::merge(self::$defaultConfig[Arr::get($config, 'driver')], $config); Base::getLog()->debug(__METHOD__ . ' merge config', ['name' => $name]); } $conn = DriverManager::getConnection($config); Base::getLog()->debug(__METHOD__ . ' create dbal connection', ['name' => $name]); // 额外注册字段类型 if (isset(self::$mappingType[Arr::get($config, 'driver')])) { $platform = $conn->getDatabasePlatform(); foreach (self::$mappingType[Arr::get($config, 'driver')] as $dbType => $doctrineType) { if (!$platform->hasDoctrineTypeMappingFor($dbType)) { Base::getLog()->debug(__METHOD__ . ' add dbal mapping type', ['raw' => $dbType, 'dbal' => $doctrineType]); $platform->registerDoctrineTypeMapping($dbType, $doctrineType); } } } Db::$instances[$name] = $conn; Base::getLog()->debug(__METHOD__ . ' save db instance', ['name' => $name]); } return Db::$instances[$name]; }
/** * @param Twig_LoaderInterface $loader * @param array $options * @return Twig_Environment */ public static function createEnvironment(Twig_LoaderInterface $loader, $options) { $environment = new Twig_Environment($loader, $options); // 缓存插件设置 $cacheProvider = new DoctrineCacheAdapter(new ArrayCache()); $cacheStrategy = new LifetimeCacheStrategy($cacheProvider); $cacheExtension = new CacheExtension($cacheStrategy); $environment->addExtension($cacheExtension); // 增加markdown支持 $engine = new MichelfMarkdownEngine(); $environment->addExtension(new MarkdownExtension($engine)); // 一些额外的html助手方法 $environment->addExtension(new Twig_Extension_HTMLHelpers()); // 自定义filter foreach (Config::load('twig')->get('filter') as $name => $filter) { $environment->addFilter(new Twig_SimpleFilter($name, $filter)); } // 自定义函数 foreach (Config::load('twig')->get('function') as $name => $function) { $environment->addFunction(new Twig_SimpleFunction($name, $function)); } // 自定义token解析器 foreach (Config::load('twig')->get('tokenParser') as $name => $tokenParser) { $environment->addTokenParser(new $tokenParser()); } return $environment; }
/** * 获取指定的配置组信息,并返回实例 * * @param string $key * @return \tourze\NoSQL\Redis\Client * @throws \tourze\NoSQL\Exception\NoSQLException */ public static function instance($key = 'default') { $instanceKey = self::instanceKey($key); if (!isset(self::$_instances[$instanceKey])) { $config = Config::load('redis')->get($key); if (!$config) { throw new NoSQLException('The requested config group not found.'); } self::$_instances[$instanceKey] = new Client(Arr::get($config, 'parameters'), Arr::get($config, 'options')); } return self::$_instances[$instanceKey]; }
/** * Creates a singleton session of the given type. Some session types * (native, database) also support restarting a session by passing a * session id as the second parameter. * $session = Session::instance(); * [!!] [Session::write] will automatically be called when the request ends. * * @param string $type type of session (native, cookie, etc) * @param string $id session identifier * @return Session */ public static function instance($type = null, $id = null) { if (null === $type) { // Use the default type $type = Session::$default; } if (!isset(Session::$instances[$type])) { $config = Config::load(self::$configFile)->get($type); $class = 'tourze\\Session\\Adapter\\' . ucfirst($type) . 'Adapter'; Session::$instances[$type] = $session = new $class($config, $id); // Write the session at shutdown register_shutdown_function([$session, 'write']); } return Session::$instances[$type]; }
public function getStasticLog($module, $interface, $startTime, $endTime, $count = 10) { $ipList = !empty($_GET['ip']) && is_array($_GET['ip']) ? $_GET['ip'] : Cache::$serverIpList; $offsetList = !empty($_GET['offset']) && is_array($_GET['offset']) ? $_GET['offset'] : []; $port = Config::load('statServer')->get('providerPort'); $requestBufferArray = []; foreach ($ipList as $key => $ip) { $offset = isset($offsetList[$key]) ? $offsetList[$key] : 0; $buffer = ['cmd' => 'get-log', 'module' => $module, 'interface' => $interface, 'start_time' => $startTime, 'end_time' => $endTime, 'offset' => $offset, 'count' => $count]; Base::getLog()->info(__METHOD__ . ' generate buffer fot getting log', $buffer); $requestBufferArray["{$ip}:{$port}"] = json_encode($buffer) . "\n"; } $readBufferArray = StatServer::multiRequest($requestBufferArray); ksort($readBufferArray); foreach ($readBufferArray as $address => $buf) { $bodyData = json_decode(trim($buf), true); $logData = isset($bodyData['data']) ? $bodyData['data'] : ''; $offset = isset($bodyData['offset']) ? $bodyData['offset'] : 0; $readBufferArray[$address] = ['offset' => $offset, 'data' => $logData]; } return $readBufferArray; }
/** * 上报统计数据 * * @param string $module * @param string $interface * @param bool $success * @param int $code * @param string $msg * @param string $reportAddress * @return boolean */ public static function report($module, $interface, $success, $code, $msg, $reportAddress = '') { // 如果msg是个数组,那么要额外处理转换成字符串 if (is_array($msg)) { // $msg格式为[':message', [':message' => 'TEST']] if (count($msg) == 2 && !Arr::isAssoc($msg) && is_array($msg[1])) { $msg = __($msg[0], $msg[1]); } } if (strpos($msg, '[ip]') !== false) { $msg = str_replace('[ip]', Arr::get($_SERVER, 'REMOTE_ADDR'), $msg); } if (strpos($msg, '[ua]') !== false) { $msg = str_replace('[ua]', Arr::get($_SERVER, 'HTTP_USER_AGENT'), $msg); } $reportAddress = $reportAddress ? $reportAddress : Config::load('statClient')->get('ip'); if (isset(self::$timeMap[$module][$interface]) && self::$timeMap[$module][$interface] > 0) { $startTime = self::$timeMap[$module][$interface]; self::$timeMap[$module][$interface] = 0; } else { if (isset(self::$timeMap['']['']) && self::$timeMap[''][''] > 0) { $startTime = self::$timeMap['']['']; self::$timeMap[''][''] = 0; } else { $startTime = microtime(true); } } //echo "\n"; //echo $startTime . "\n"; $endTime = microtime(true); //echo $endTime . "\n"; $costTime = $endTime - $startTime; //echo $costTime . "\n"; $binData = Protocol::encode($module, $interface, $costTime, $success, $code, $msg); Base::getLog()->debug(__METHOD__ . ' prepare bin data', ['bin' => $binData]); return self::sendData($reportAddress, $binData); }
public function actionIndex() { $act = isset($_GET['act']) ? $_GET['act'] : 'home'; $errorMsg = $noticeMsg = $successMsg = $ipListStr = ''; $action = 'save-server-list'; switch ($act) { case 'detect-server': // 创建udp socket $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); socket_set_option($socket, SOL_SOCKET, SO_BROADCAST, 1); $buffer = json_encode(['cmd' => 'REPORT_IP']) . "\n"; // 广播 socket_sendto($socket, $buffer, strlen($buffer), 0, '255.255.255.255', Config::load('statServer')->get('providerPort')); // 超时相关 $time_start = microtime(true); $global_timeout = 1; $ipList = []; $recv_timeout = ['sec' => 0, 'usec' => 8000]; socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, $recv_timeout); // 循环读数据 while (microtime(true) - $time_start < $global_timeout) { $buf = $host = $port = ''; if (@socket_recvfrom($socket, $buf, 65535, 0, $host, $port)) { $ipList[$host] = $host; } } // 过滤掉已经保存的ip $count = 0; foreach ($ipList as $ip) { if (!isset(Cache::$serverIpList[$ip])) { $ipListStr .= $ip . "\r\n"; $count++; } } $action = 'add-to-server-list'; $noticeMsg = "探测到{$count}个新数据源"; break; case 'add-to-server-list': if (empty($_POST['ip_list'])) { $errorMsg = "保存的ip列表为空"; break; } $ipList = explode("\n", $_POST['ip_list']); if ($ipList) { foreach ($ipList as $ip) { $ip = trim($ip); if (false !== ip2long($ip)) { Cache::$serverIpList[$ip] = $ip; } } } $successMsg = "添加成功"; foreach (Cache::$serverIpList as $ip) { $ipListStr .= $ip . "\r\n"; } break; case 'save-server-list': if (empty($_POST['ip_list'])) { $errorMsg = "保存的ip列表为空"; break; } Cache::$serverIpList = []; $ipList = explode("\n", $_POST['ip_list']); if ($ipList) { foreach ($ipList as $ip) { $ip = trim($ip); if (false !== ip2long($ip)) { Cache::$serverIpList[$ip] = $ip; } } } $successMsg = "保存成功"; foreach (Cache::$serverIpList as $ip) { $ipListStr .= $ip . "\r\n"; } break; default: foreach (Cache::$serverIpList as $ip) { $ipListStr .= $ip . "\r\n"; } } $this->template->set('admin/index', ['act' => $act, 'action' => $action, 'successMsg' => $successMsg, 'noticeMsg' => $noticeMsg, 'errorMsg' => $errorMsg, 'ipListStr' => $ipListStr]); }
/** * 测试配置加载功能 * * @dataProvider dataLoad * @param mixed $file * @param mixed $name * @param mixed $expected */ public function testLoad($file, $name, $expected) { $this->assertEquals($expected, Config::load($file)->get($name)); }
<?php use tourze\Base\Config; use tourze\Base\I18n; use tourze\Base\Message; if (is_file(__DIR__ . '/vendor/autoload.php')) { require __DIR__ . '/vendor/autoload.php'; } // 指定配置加载目录 Config::addPath(__DIR__ . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR); // 语言文件目录 I18n::addPath(__DIR__ . DIRECTORY_SEPARATOR . 'i18n' . DIRECTORY_SEPARATOR); // Message目录 Message::addPath(__DIR__ . DIRECTORY_SEPARATOR . 'message' . DIRECTORY_SEPARATOR);
<?php use tourze\Base\Config; use tourze\Route\Route; use tourze\StatServer\Cache; use tourze\View\View; if (is_file(__DIR__ . '/vendor/autoload.php')) { require_once __DIR__ . '/vendor/autoload.php'; } ini_set('display_errors', 'on'); if (!defined('ROOT_PATH')) { define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR); } if (!defined('WEB_PATH')) { define('WEB_PATH', ROOT_PATH . 'web' . DIRECTORY_SEPARATOR); } Config::addPath(ROOT_PATH . 'config' . DIRECTORY_SEPARATOR); View::addPath(ROOT_PATH . 'view' . DIRECTORY_SEPARATOR); Cache::$serverIpList = Config::load('statServer')->get('serverIpList'); // 指定控制器命名空间 Route::$defaultNamespace = '\\tourze\\StatServer\\Controller\\'; Route::set('stat-web', '(<controller>(/<action>(/<id>)))')->defaults(['controller' => 'Main', 'action' => 'index']); // 创建类别名 @class_alias('\\tourze\\StatServer\\Protocol\\Statistic', '\\Workerman\\Protocols\\Statistic');
/** * 加载指定的配置 * * @param string $name * @return bool * @throws \tourze\Server\Exception\BaseException */ public static function load($name) { if (!($config = Config::load('main')->get('server.' . $name))) { throw new BaseException('The requested config not found.'); } if (!($socketName = Arr::get($config, 'socketName'))) { throw new BaseException('The socket name should not be empty.'); } $config['name'] = $name; // 如果有自定义初始化的class名 if (isset($config['initClass'])) { $class = $config['initClass']; unset($config['initClass']); new $class($config); } else { // 根据socketName来判断,如果是http的话,有单独的处理 if (substr($socketName, 0, 4) == 'http') { new Web($config); } else { new Worker($config); } } return true; }
/** * 入口 */ public function actionIndex() { $date = $this->request->query('date'); if (!$date) { $date = date('Y-m-d'); } $errorMsg = $noticeMsg = ''; $module = 'WorkerMan'; $interface = 'Statistics'; $today = date('Y-m-d'); $timeNow = time(); StatServer::multiRequestStAndModules($module, $interface, $date); $allStr = ''; if (is_array(Cache::$statisticData['statistic'])) { foreach (Cache::$statisticData['statistic'] as $ip => $st_str) { $allStr .= $st_str; } } $codeMap = []; $data = StatServer::formatStatLog($allStr, $date, $codeMap); $successSeriesData = $failSeriesData = $successTimeSeriesData = $failTimeSeriesData = []; $totalCount = $fail_count = 0; foreach ($data as $time_point => $item) { if ($item['total_count']) { $successSeriesData[] = "[" . $time_point * 1000 . ",{$item['total_count']}]"; $totalCount += $item['total_count']; } $failSeriesData[] = "[" . $time_point * 1000 . ",{$item['fail_count']}]"; $fail_count += $item['fail_count']; if ($item['total_avg_time']) { $successTimeSeriesData[] = "[" . $time_point * 1000 . ",{$item['total_avg_time']}]"; } $failTimeSeriesData[] = "[" . $time_point * 1000 . ",{$item['fail_avg_time']}]"; } $successSeriesData = implode(',', $successSeriesData); $failSeriesData = implode(',', $failSeriesData); $successTimeSeriesData = implode(',', $successTimeSeriesData); $failTimeSeriesData = implode(',', $failTimeSeriesData); // 总体成功率 $globalRate = $totalCount ? round(($totalCount - $fail_count) / $totalCount * 100, 4) : 100; // 返回码分布 $codePieData = ''; $codePieArray = []; unset($codeMap[0]); if (empty($codeMap)) { $codeMap[0] = $totalCount > 0 ? $totalCount : 1; } if (is_array($codeMap)) { $total_item_count = array_sum($codeMap); foreach ($codeMap as $code => $count) { $codePieArray[] = "[\"{$code}:{$count}个\", " . round($count * 100 / $total_item_count, 4) . "]"; } $codePieData = implode(',', $codePieArray); } unset($_GET['start_time'], $_GET['end_time'], $_GET['date'], $_GET['fn']); $query = http_build_query($_GET); // 删除末尾0的记录 if ($today == $date) { while (!empty($data) && ($item = end($data)) && $item['total_count'] == 0 && ($key = key($data)) && $timeNow < $key) { unset($data[$key]); } } if (Cache::$lastFailedIpArray) { $errorMsg = '<strong>无法从以下数据源获取数据:</strong>'; foreach (Cache::$lastFailedIpArray as $ip) { $errorMsg .= $ip . ':' . Config::load('statServer')->get('providerPort') . ' '; } } $this->template->set('content', View::factory('main/index', ['date' => $date, 'query' => $query, 'interfaceName' => '整体', 'errorMsg' => $errorMsg, 'noticeMsg' => $noticeMsg, 'data' => $data, 'successSeriesData' => $successSeriesData, 'failSeriesData' => $failSeriesData, 'successTimeSeriesData' => $successTimeSeriesData, 'failTimeSeriesData' => $failTimeSeriesData, 'globalRate' => $globalRate, 'codePieData' => $codePieData])); }
/** * 获取指定时间段的日志 * * @param string $module * @param string $interface * @param string $startTime * @param string $endTime * @param string $code * @param string $msg * @param string $offset * @param int $count * @return array */ protected function getStasticLog($module, $interface, $startTime = '', $endTime = '', $code = '', $msg = '', $offset = '', $count = 100) { // log文件 $logFile = Config::load('statServer')->get('dataPath') . $this->logDir . (empty($startTime) ? date('Y-m-d') : date('Y-m-d', $startTime)); if (!is_readable($logFile)) { return ['offset' => 0, 'data' => '']; } // 读文件 $h = fopen($logFile, 'r'); // 如果有时间,则进行二分查找,加速查询 if ($startTime && $offset == 0 && ($file_size = filesize($logFile)) > 1024000) { $offset = $this->binarySearch(0, $file_size, $startTime - 1, $h); $offset = $offset < 100000 ? 0 : $offset - 100000; } // 正则表达式 $pattern = "/^([\\d: \\-]+)\t\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\t"; if ($module && $module != 'WorkerMan') { $pattern .= $module . "::"; } else { $pattern .= ".*::"; } if ($interface && $module != 'WorkerMan') { $pattern .= $interface . "\t"; } else { $pattern .= ".*\t"; } if ($code !== '') { $pattern .= "code:{$code}\t"; } else { $pattern .= "code:\\d+\t"; } if ($msg) { $pattern .= "msg:{$msg}"; } $pattern .= '/'; // 指定偏移位置 if ($offset > 0) { fseek($h, (int) $offset - 1); } // 查找符合条件的数据 $now_count = 0; $log_buffer = ''; while (1) { if (feof($h)) { break; } // 读1行 $line = fgets($h); if (preg_match($pattern, $line, $match)) { // 判断时间是否符合要求 $time = strtotime($match[1]); if ($startTime) { if ($time < $startTime) { continue; } } if ($endTime) { if ($time > $endTime) { break; } } // 收集符合条件的log $log_buffer .= $line; if (++$now_count >= $count) { break; } } } // 记录偏移位置 $offset = ftell($h); return ['offset' => $offset, 'data' => $log_buffer]; }
/** * 准备module参数,并读取数据 * * @param string $module * @param string $interface * @param mixed $date */ public static function multiRequestStAndModules($module, $interface, $date) { Base::getLog()->info(__METHOD__ . ' calling multiRequestStAndModules - start'); Cache::$statisticData['statistic'] = ''; $buffer = ['cmd' => 'get-statistic', 'module' => $module, 'interface' => $interface, 'date' => $date]; Base::getLog()->info(__METHOD__ . ' prepare buffer', $buffer); $buffer = json_encode($buffer) . "\n"; $ipList = !empty($_GET['ip']) && is_array($_GET['ip']) ? $_GET['ip'] : Cache::$serverIpList; $requestBufferArray = []; $port = Config::load('statServer')->get('providerPort'); foreach ($ipList as $ip) { $requestBufferArray["{$ip}:{$port}"] = $buffer; } $readBufferArray = self::multiRequest($requestBufferArray); Base::getLog()->info(__METHOD__ . ' receive remote buffer', $readBufferArray); foreach ($readBufferArray as $address => $buf) { $temp = explode(':', $address); $ip = array_shift($temp); $bodyData = json_decode(trim($buf), true); $statData = Arr::get($bodyData, 'statistic', ''); $modulesData = Arr::get($bodyData, 'modules', []); // 整理modules foreach ($modulesData as $mod => $interfaces) { if (!isset(Cache::$moduleData[$mod])) { Cache::$moduleData[$mod] = []; } foreach ($interfaces as $if) { Cache::$moduleData[$mod][$if] = $if; } } Cache::$statisticData['statistic'][$ip] = $statData; } Base::getLog()->info(__METHOD__ . ' calling multiRequestStAndModules - end'); }
/** * 默认动作 */ public function actionIndex() { $module = $this->request->query('module'); $interface = $this->request->query('interface'); $date = $this->request->query('date'); if (!$date) { $date = date('Y-m-d'); } $errorMsg = ''; $today = date('Y-m-d'); $timeNow = time(); StatServer::multiRequestStAndModules($module, $interface, $date); $allStr = ''; if (is_array(Cache::$statisticData['statistic'])) { foreach (Cache::$statisticData['statistic'] as $ip => $st_str) { $allStr .= $st_str; } } $codeMap = []; $data = StatServer::formatStatLog($allStr, $date, $codeMap); $interfaceName = "{$module}::{$interface}"; $successSeriesData = $failSeriesData = $successTimeSeriesData = $failTimeSeriesData = []; $totalCount = $failCount = 0; foreach ($data as $timePoint => $item) { if ($item['total_count']) { $successSeriesData[] = "[" . $timePoint * 1000 . ",{$item['total_count']}]"; $totalCount += $item['total_count']; } $failSeriesData[] = "[" . $timePoint * 1000 . ",{$item['fail_count']}]"; $failCount += $item['fail_count']; if ($item['total_avg_time']) { $successTimeSeriesData[] = "[" . $timePoint * 1000 . ",{$item['total_avg_time']}]"; } $failTimeSeriesData[] = "[" . $timePoint * 1000 . ",{$item['fail_avg_time']}]"; } $successSeriesData = implode(',', $successSeriesData); $failSeriesData = implode(',', $failSeriesData); $successTimeSeriesData = implode(',', $successTimeSeriesData); $failTimeSeriesData = implode(',', $failTimeSeriesData); unset($_GET['start_time'], $_GET['end_time'], $_GET['date'], $_GET['fn']); $query = http_build_query($_GET); // 删除末尾0的记录 if ($today == $date) { while (!empty($data) && ($item = end($data)) && $item['total_count'] == 0 && ($key = key($data)) && $timeNow < $key) { unset($data[$key]); } } $tableData = $htmlClass = ''; if ($data) { $firstLine = true; foreach ($data as $item) { if ($firstLine) { $firstLine = false; if ($item['total_count'] == 0) { continue; } } $htmlClass = 'class="danger"'; if ($item['total_count'] == 0) { $htmlClass = ''; } elseif ($item['percent'] >= 99.98999999999999) { $htmlClass = 'class="success"'; } elseif ($item['percent'] >= 99) { $htmlClass = ''; } elseif ($item['percent'] >= 98) { $htmlClass = 'class="warning"'; } $tableData .= "\n<tr {$htmlClass}>\n <td>{$item['time']}</td>\n <td>{$item['total_count']}</td>\n <td> {$item['total_avg_time']}</td>\n <td>{$item['success_count']}</td>\n <td>{$item['suc_avg_time']}</td>\n <td>" . ($item['fail_count'] > 0 ? "<a href='" . Route::url('stat-web', ['controller' => 'Logger']) . "?{$query}&start_time=" . (strtotime($item['time']) - 300) . "&end_time=" . strtotime($item['time']) . "'>{$item['fail_count']}</a>" : $item['fail_count']) . "</td>\n <td>{$item['fail_avg_time']}</td>\n <td>{$item['percent']}%</td>\n </tr>\n "; } } // date btn $dateBtnStr = ''; for ($i = 13; $i >= 1; $i--) { $theTime = strtotime("-{$i} day"); $theDate = date('Y-m-d', $theTime); $htmlTheDate = $date == $theDate ? "<b>{$theDate}</b>" : $theDate; $dateBtnStr .= '<a href="' . Route::url('stat-web', ['controller' => 'Statistic']) . '?date=' . "{$theDate}&{$query}" . '" class="btn ' . $htmlClass . '" type="button">' . $htmlTheDate . '</a>'; if ($i == 7) { $dateBtnStr .= '</br>'; } } $theDate = date('Y-m-d'); $htmlTheDate = $date == $theDate ? "<b>{$theDate}</b>" : $theDate; $dateBtnStr .= '<a href="' . Route::url('stat-web', ['controller' => 'Statistic']) . '?date=' . "{$theDate}&{$query}" . '" class="btn" type="button">' . $htmlTheDate . '</a>'; $moduleStr = ''; foreach (Cache::$moduleData as $mod => $interfaces) { if ($mod == 'WorkerMan') { continue; } $moduleStr .= '<li><a href="' . Route::url('stat-web', ['controller' => 'Statistic']) . '?module=' . $mod . '">' . $mod . '</a></li>'; if ($module == $mod) { foreach ($interfaces as $if) { $moduleStr .= '<li> <a href="' . Route::url('stat-web', ['controller' => 'Statistic']) . '?module=' . $mod . '&interface=' . $if . '">' . $if . '</a></li>'; } } } if (Cache::$lastFailedIpArray) { $errorMsg = '<strong>无法从以下数据源获取数据:</strong>'; foreach (Cache::$lastFailedIpArray as $ip) { $errorMsg .= $ip . '::' . Config::load('statServer')->get('providerPort') . ' '; } } $this->template->set('content', View::factory('statistic/index', ['errorMsg' => $errorMsg, 'date' => $date, 'module' => $module, 'interface' => $interface, 'interfaceName' => $interfaceName, 'moduleStr' => $moduleStr, 'successSeriesData' => $successSeriesData, 'failSeriesData' => $failSeriesData, 'successTimeSeriesData' => $successTimeSeriesData, 'failTimeSeriesData' => $failTimeSeriesData, 'tableData' => $tableData, 'dateBtnStr' => $dateBtnStr])); }
/** * 获取指定组件 * * @param string $name * @return \tourze\Base\Component * @throws \tourze\Base\Exception\ComponentNotFoundException * @return Component|object */ public static function get($name) { if (!isset(self::$components[$name])) { // 检查配置表是否有记录 if (!($config = Config::load('main')->get('component.' . $name))) { throw new ComponentNotFoundException('The requested component [:component] not found.', [':component' => $name]); } self::set($name, $config); } return self::$components[$name]; }
/** * 初始化,和更新数据数组 */ public static function initMimeTypes() { if (empty(self::$mimeTypes)) { self::setMimeTypes(Config::load(self::getConfigName())->asArray()); } }