Todaymade\Daux\Daux::initializeConfiguration PHP Метод

initializeConfiguration() публичный Метод

public initializeConfiguration ( string $override_file = null )
$override_file string
    public function initializeConfiguration($override_file = null)
    {
        $params = $this->getParams();
        // Validate and set theme path
        $params->setDocumentationDirectory($docs_path = $this->normalizeDocumentationPath($this->getParams()->getDocumentationDirectory()));
        // Read documentation overrides
        $this->loadConfiguration($docs_path . DIRECTORY_SEPARATOR . 'config.json');
        // Read command line overrides
        $override_file = $this->getConfigurationOverride($override_file);
        if ($override_file != null) {
            $params->setConfigurationOverrideFile($override_file);
            $this->loadConfiguration($override_file);
        }
        // Validate and set theme path
        $params->setThemesPath($this->normalizeThemePath($params->getThemesDirectory()));
        // Set a valid default timezone
        if ($params->hasTimezone()) {
            date_default_timezone_set($params->getTimezone());
        } elseif (!ini_get('date.timezone')) {
            date_default_timezone_set('GMT');
        }
    }

Usage Example

Пример #1
0
 /**
  * Serve the documentation
  *
  * @throws Exception
  */
 public static function serve()
 {
     $daux = new Daux(Daux::LIVE_MODE);
     $daux->initializeConfiguration();
     $class = $daux->getProcessorClass();
     if (!empty($class)) {
         $daux->setProcessor(new $class($daux, new NullOutput(), 0));
     }
     // Set this critical configuration
     // for the tree generation
     $daux->getParams()['index_key'] = 'index';
     // Improve the tree with a processor
     $daux->generateTree();
     $server = new static($daux);
     try {
         $page = $server->handle($_REQUEST);
     } catch (NotFoundException $e) {
         http_response_code(404);
         $page = new ErrorPage('An error occured', $e->getMessage(), $daux->getParams());
     }
     if ($page instanceof RawPage) {
         header('Content-type: ' . MimeType::get($page->getFile()));
         // Transfer file in 1024 byte chunks to save memory usage.
         if ($fd = fopen($page->getFile(), 'rb')) {
             while (!feof($fd)) {
                 echo fread($fd, 1024);
             }
             fclose($fd);
         }
         return;
     }
     header('Content-type: text/html; charset=utf-8');
     echo $page->getContent();
 }
All Usage Examples Of Todaymade\Daux\Daux::initializeConfiguration