/** * write yaml to file * * @param string $path * @param mixed $data */ function run($path, $data) { if (extension_loaded('yaml')) { $this->logAction('yaml', $path); Helper::put($path, yaml_emit($data)); } else { $this->getLogger()->error('yaml extension not found.'); } }
/** * render code template to file * * $this->render('template.php.twig','target.php', array( * ... * )); * * @param string $templateFile template file path (related from ResourceDir) * @param string $target path to target file. */ function run($templateFile, $target, $args = array()) { $rsDir = $this->getResourceDir(); $loader = new Twig_Loader_Filesystem(array($rsDir)); $twig = new Twig_Environment($loader, array()); // XXX: register some built-in template for php doc or code. $template = $twig->loadTemplate($templateFile); $output = $template->render($args); $this->logAction('render', $target); Helper::put($target, $output); }
/** * file create operation * * @param string $file target file path * @param string $content file content */ function run($file, $content) { $this->logAction('create', $file); Helper::put($file, $content); }
/** * write json file * * @param string $file path to file * @param mixed structural data */ function run($file, $data) { $this->logAction('create', $file); Helper::put($file, json_encode($data)); }