/** * Возвращает нужное соединение. * @todo после перехода на 5.5 сделать приватным * @param string $name * @return AbstractConnection */ public function getConnection($name) { if (!isset($this->Connections[$name])) { $config = Config::getInstance()->get(self::MYSQL_CONFIG_NAME, $name); $Connection = new MySQLConnection(); $Connection->setHost($config['host'])->setLogin($config['login'])->setPassword($config['password']); $this->Connections[$name] = $Connection; } return $this->Connections[$name]; }
/** * Создаем объект логгера нужного типа. * @param string $type Тип логгера. * @return Logger Экземпляр логгера. */ private static function createLogger($type) { $Logger = new Logger($type); foreach (Config::getInstance()->get('logger', 'handlers') as $handlerType => $handlerConfig) { $Handler = static::createHandler($handlerType, $handlerConfig); if (!$Handler) { continue; } $Handler->setFormatter(static::createLogFormatter($handlerConfig)); $Logger->pushHandler($Handler); } $Logger->pushProcessor(new GlobalContextProcessor()); return $Logger; }
<?php use stalk\Config\Config; include_once 'constants.php'; // Регистрация загрузки классов проекта. spl_autoload_register(function ($className) { try { include_once SRC_DIR . str_replace('\\', '/', $className) . FILE_EXT; } catch (Exception $Ex) { } }); // Регистрация автозагрузчиков внешних библиотек. require CLASS_COMPOSER_AUTOLOADER; // определение путей конфига Config::getInstance()->setConfigDir(CONFIG_DIR . APPLICATION_PLATFORM . '/');
/** * Конструктор. * @throws ConfigKeyNotFoundException */ public function __construct() { $this->listen = Config::getInstance()->get(self::CONFIG_NAME, 'listen'); $this->names = Config::getInstance()->get(self::CONFIG_NAME, 'serverNames'); $this->fastcgi = Config::getInstance()->get(self::CONFIG_NAME, 'fastcgi'); $this->includeFastCgiConfPath = $this->getTemplateDir() . self::FASTCGI_CONF_FILE_NAME; $this->includeNoCachePath = $this->getTemplateDir() . self::NO_CACHE_FILE_NAME; $this->coreLocationPath = $this->getTemplateDir() . self::CORE_LOCATION_TEMPLATE_FILE_NAME; $this->vhostPath = $this->getTemplateDir() . self::VHOST_TEMPLATE_FILE_NAME; $this->includeSslPath = $this->getTemplateDir() . self::SSL_FILE_NAME; }