예제 #1
0
 /**
  * @expectedException \Exception
  */
 public function testCantSaveTheContent()
 {
     $builderOptions = new OptionsBuilder();
     $builderOptions->setApiName('testApp');
     $builderOptions->setOutputDir('build/test');
     $builderOptions->setOutputFile('test.html');
     if (!file_exists($builderOptions->getOutputDir())) {
         mkdir($builderOptions->getOutputDir(), 0600, TRUE);
     }
     $this->builder = new Builder(array('Zckrs\\GenDocApi\\Test\\Client'), $builderOptions);
     $this->builder->generate();
 }
예제 #2
0
 private function saveTemplate($content, $anchorMenu, $file)
 {
     $oldContent = $this->getTemplate('layout.html');
     $arrayCss = array();
     $arrayCss[] = $this->getAsset('css/css.css');
     $arrayJs = array();
     $arrayJs[] = $this->getAsset('js/js.js');
     $tr = array('{{ app_name }}' => $this->options->getApiName(), '{{ app_description }}' => $this->options->getApiDescription(), '{{ content }}' => $content, '{{ anchor_menu }}' => $anchorMenu, '{{ date }}' => date('Y-m-d, H:i:s'), '{{ version }}' => static::VERSION, '{{ css }}' => implode(PHP_EOL, $arrayCss), '{{ js }}' => implode(PHP_EOL, $arrayJs));
     $newContent = strtr($oldContent, $tr);
     if (!is_dir($this->options->getOutputDir()) && !@mkdir($this->options->getOutputDir())) {
         throw new \Exception("Cannot create directory " . $this->options->getOutputDir() . "\n");
     }
     if (!@file_put_contents($this->options->getOutputDir() . '/' . $file, $newContent)) {
         throw new \Exception("Cannot save the content to " . $this->options->getOutputDir() . "\n");
     }
 }