Пример #1
0
 protected function boot()
 {
     try {
         $src_dir = DirectoryHelper::slashDirname(dirname(__DIR__));
         $base_dir = DirectoryHelper::slashDirname(dirname($src_dir));
         $tmp_dir = DirectoryHelper::slashDirname($base_dir . 'tmp');
         Helper::ensureDirectoryExists($tmp_dir);
         if (!is_writable($tmp_dir)) {
             throw new \Exception("Directory '{$tmp_dir}' must be writable!");
         }
         $cache_dir = DirectoryHelper::slashDirname($tmp_dir . 'cache');
         Helper::ensureDirectoryExists($cache_dir);
         if (!is_writable($cache_dir)) {
             throw new \Exception("Directory '{$cache_dir}' must be writable!");
         }
         $i18n_dir = DirectoryHelper::slashDirname($tmp_dir . 'i18n');
         Helper::ensureDirectoryExists($i18n_dir);
         if (!is_writable($i18n_dir)) {
             throw new \Exception("Directory '{$i18n_dir}' must be writable!");
         }
         $log_dir = DirectoryHelper::slashDirname($tmp_dir . 'log');
         Helper::ensureDirectoryExists($log_dir);
         if (!is_writable($log_dir)) {
             throw new \Exception("Directory '{$log_dir}' must be writable!");
         }
         $this->addPath('app_manifest', $base_dir . self::APP_MANIFEST)->addPath('base_dir_http', $base_dir . 'www/')->addPath('base_dir', $src_dir)->addPath('root_dir', $base_dir)->addPath('tmp', $base_dir . 'tmp/')->addPath('cache', $base_dir . 'tmp/cache/')->addPath('i18n', $base_dir . 'tmp/i18n/')->addPath('logs', $base_dir . 'tmp/log/')->addPath('base_templates', $src_dir . self::TEMPLATES_DIR);
         if (file_exists($base_dir . self::USER_DIR)) {
             $this->addPath('user_dir', $base_dir . self::USER_DIR);
             if (file_exists($base_dir . self::USER_DIR . '/' . self::TEMPLATES_DIR)) {
                 $this->addPath('user_templates', $base_dir . self::USER_DIR . '/' . self::TEMPLATES_DIR);
             }
         }
     } catch (\Exception $e) {
         header('Content-Type: text/plain');
         echo PHP_EOL . '[DocBook startup error] : ' . $e->getMessage() . PHP_EOL;
         echo PHP_EOL . '-------------------------' . PHP_EOL;
         echo 'For more info, see the "INSTALL.md" file.' . PHP_EOL;
         exit(1);
     }
 }