Ejemplo n.º 1
0
 protected function prepareDaux(InputInterface $input)
 {
     $daux = new Daux(Daux::STATIC_MODE);
     // Set the format if requested
     if ($input->getOption('format')) {
         $daux->getParams()['format'] = $input->getOption('format');
     }
     // Set the source directory
     if ($input->getOption('source')) {
         $daux->getParams()['docs_directory'] = $input->getOption('source');
     }
     $daux->setDocumentationPath($daux->getParams()['docs_directory']);
     $daux->setThemesPath($daux->getParams()['themes_directory']);
     $daux->initializeConfiguration($input->getOption('configuration'));
     return $daux;
 }
Ejemplo n.º 2
0
 /**
  * Serve the documentation
  *
  * @throws Exception
  */
 public static function serve()
 {
     $daux = new Daux(Daux::LIVE_MODE);
     $daux->setThemesPath($daux->getParams()['themes_directory']);
     $daux->setDocumentationPath($daux->getParams()['docs_directory']);
     $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)) {
                 print fread($fd, 1024);
             }
             fclose($fd);
         }
         return;
     }
     header('Content-type: text/html; charset=utf-8');
     echo $page->getContent();
 }