rebaseConfiguration() публичный статический Метод

Set a new base_url for the configuration
public static rebaseConfiguration ( Config $config, string $base_url )
$config Config
$base_url string
Пример #1
0
 /**
  * Recursively generate the documentation
  *
  * @param Directory $tree
  * @param string $output_dir
  * @param \Todaymade\Daux\Config $params
  * @param OutputInterface $output
  * @param integer $width
  * @param string $base_url
  * @throws \Exception
  */
 private function generateRecursive(Directory $tree, $output_dir, $params, $output, $width, $base_url = '')
 {
     DauxHelper::rebaseConfiguration($params, $base_url);
     if ($base_url !== '' && empty($params['entry_page'])) {
         $params['entry_page'] = $tree->getFirstPage();
     }
     foreach ($tree->getEntries() as $key => $node) {
         if ($node instanceof Directory) {
             $new_output_dir = $output_dir . DIRECTORY_SEPARATOR . $key;
             mkdir($new_output_dir);
             $this->generateRecursive($node, $new_output_dir, $params, $output, $width, '../' . $base_url);
             // Rebase configuration again as $params is a shared object
             DauxHelper::rebaseConfiguration($params, $base_url);
         } else {
             $this->runAction("- " . $node->getUrl(), $output, $width, function () use($node, $output_dir, $key, $params) {
                 if (!$node instanceof Content) {
                     copy($node->getPath(), $output_dir . DIRECTORY_SEPARATOR . $key);
                     return;
                 }
                 $generated = $this->generateOne($node, $params);
                 file_put_contents($output_dir . DIRECTORY_SEPARATOR . $key, $generated->getContent());
             });
         }
     }
 }
Пример #2
0
 /**
  * @return \Todaymade\Daux\Config
  */
 public function getParams()
 {
     $params = $this->daux->getParams();
     $params['host'] = $this->host;
     DauxHelper::rebaseConfiguration($params, '//' . $this->base_url);
     $params['base_page'] = '//' . $this->base_url;
     if (!$this->daux->options['live']['clean_urls']) {
         $params['base_page'] .= 'index.php/';
     }
     return $params;
 }
Пример #3
0
 /**
  * @return \Todaymade\Daux\Config
  */
 public function getParams()
 {
     $params = $this->daux->getParams();
     $params['host'] = $this->host;
     DauxHelper::rebaseConfiguration($params, '//' . $this->base_url);
     $params['base_page'] = '//' . $this->base_url;
     if (!$this->daux->options['live']['clean_urls']) {
         $params['base_page'] .= 'index.php/';
     }
     // Text search would be too slow on live server
     $params['html']['search'] = false;
     return $params;
 }
Пример #4
0
 /**
  * Recursively generate the documentation
  *
  * @param Directory $tree
  * @param string $output_dir
  * @param \Todaymade\Daux\Config $params
  * @param OutputInterface $output
  * @param int $width
  * @param bool $index_pages
  * @param string $base_url
  * @throws \Exception
  */
 private function generateRecursive(Directory $tree, $output_dir, $params, $output, $width, $index_pages, $base_url = '')
 {
     DauxHelper::rebaseConfiguration($params, $base_url);
     if ($base_url !== '' && empty($params['entry_page'])) {
         $params['entry_page'] = $tree->getFirstPage();
     }
     foreach ($tree->getEntries() as $key => $node) {
         if ($node instanceof Directory) {
             $new_output_dir = $output_dir . DIRECTORY_SEPARATOR . $key;
             mkdir($new_output_dir);
             $this->generateRecursive($node, $new_output_dir, $params, $output, $width, $index_pages, '../' . $base_url);
             // Rebase configuration again as $params is a shared object
             DauxHelper::rebaseConfiguration($params, $base_url);
         } else {
             $this->runAction('- ' . $node->getUrl(), $output, $width, function () use($node, $output_dir, $key, $params, $index_pages) {
                 if ($node instanceof Raw) {
                     copy($node->getPath(), $output_dir . DIRECTORY_SEPARATOR . $key);
                     return;
                 }
                 $generated = $this->generateOne($node, $params);
                 file_put_contents($output_dir . DIRECTORY_SEPARATOR . $key, $generated->getContent());
                 if ($index_pages) {
                     $this->indexed_pages[] = ['title' => $node->getTitle(), 'text' => utf8_encode($this->strip_html_tags($generated->getPureContent())), 'tags' => '', 'url' => $node->getUrl()];
                 }
             });
         }
     }
 }