示例#1
0
 public function create($path_file_generate, $data = array(), $ext = '.php')
 {
     $trans = array();
     $options = $this->data;
     $path_template = __DIR__ . '/templates/' . $this->template . '.php';
     if (!is_file($path_template)) {
         throw new \Exception("La plantilla \"{$this->template}\" no existe para generar.");
     }
     ob_start();
     require $path_template;
     $content = ob_get_clean();
     $trans['##NAMESPACE##'] = $this->namespace ? $this->namespace : '';
     $trans['##CLASS##'] = $this->name_class ? $this->name_class : '';
     $trans['##EXTENDS##'] = $this->name_class_extend ? 'extends ' . $this->name_class_extend : '';
     $content = strtr($content, $trans);
     $content = str_replace(array('[?php', '[?=', '?]'), array('<?php', '<?php echo', '?>'), $content);
     \Kodazzi\Tools\File::write($path_file_generate . $ext, $content);
 }