/** * @param null $name * * @return Database * @throws ErrorException */ protected static function _instance($name = NULL) { if (!class_exists('Kohana_Database')) { throw new ErrorException('Kohana_Database module not loaded'); } $name = static::instanceName($name); if (!array_key_exists($name, static::$transactions)) { static::$transactions[$name] = FALSE; } return Kohana_Database::instance($name); }
Kohana::init(array('base_url' => '/', 'index_file' => '')); /** * Attach the file write to logging. Multiple writers are supported. */ Kohana::$log->attach(new Log_File(APPPATH . 'logs')); /** * Attach a file reader to config. Multiple readers are supported. */ Kohana::$config->attach(new Config_File()); // Sessions & Cookies Session::$default = 'native'; /** * Enable modules. Modules are referenced by a relative or absolute path. */ Kohana::modules(array('auth' => MODPATH . 'auth', 'cache' => MODPATH . 'cache', 'database' => MODPATH . 'database', 'orm' => MODPATH . 'orm', 'email' => MODPATH . 'email')); Kohana::$config->attach(new Config_Database(array('instance' => Kohana_Database::instance(), 'table_name' => 'config'))); /** * Set the routes. Each route must have a minimum of a name, a URI and a set of * defaults for the URI. */ // Админ роут по-умолчанию Route::set('admin', 'admin(/<controller>(/<action>(/<id>)))', array('id' => '.+'))->defaults(array('directory' => 'admin', 'controller' => 'main', 'action' => 'index')); // Если сайт оффлайн Route::set('offline', 'offline')->defaults(array('directory' => 'site', 'controller' => 'main', 'action' => 'offline')); // Обработчик ошибок Route::set('error', 'error/<action>(/<message>)', array('action' => '[0-9]++', 'message' => '.+'))->defaults(array('controller' => 'error')); // Роут каталога Route::set('catalias', 'c/<catalias>', array('catalias' => '.+'))->defaults(array('directory' => 'site', 'controller' => 'catalog', 'action' => 'index')); // Роут страницы БЕЗ каталога Route::set('pagealias', '(<catalias>/)<pagealias>', array('catalias' => '.+', 'pagealias' => '.+'))->defaults(array('directory' => 'site', 'controller' => 'page', 'action' => 'index')); // Роут по-умолчанию