public static function putMcData() { if (session_id() == "") { session_start(); } $instance = new self(); $_SESSION['mcData'] = $instance->generate(); }
/** * 获取处理后的模板文件路径 * * @param string $srcTplpath * tpl文件如/path/new.tpl * @param boolean $useCache * 是否使用已存在的编译后的文件,默认为true * @throws Exception * @return string */ public static function includeTpl($srcTplpath, $useCache = true) { if (!defined('IN_TEMPLATE_L')) { define('IN_TEMPLATE_L', true); } $tpl = new self(); $tplPath = $tpl->getTplRealpath($srcTplpath); if (!is_file($tplPath)) { throw new Exception('template[' . $srcTplpath . '] not found in ' . $tplPath); } $distPath = $tpl->getTplRealpath($srcTplpath, false); // if (defined('APP_DEBUG')) { $useCache = false; } // 如果预处理后的文件存在,且指定使用缓存,则直接返回路径 if ($useCache && is_file($distPath)) { return $distPath; } $distPathDir = dirname($distPath); if (!is_dir($distPathDir)) { if (!mkdir($distPathDir, 0777, true)) { throw new Exception('failed to create dist dir ' . $distPathDir . ' for template[' . $srcTplpath . ']'); } } $content = $tpl->generate($srcTplpath); $handle = @fopen($distPath, 'w'); if ($handle === false) { throw new Exception('failed to write data to ' . $distPath . ' for template[' . $srcTplpath . ']'); } else { fwrite($handle, $content); fclose($handle); } return $distPath; }
public static function main(array $argv) { $args = \Docopt::handle(self::DOC, array('argv' => \array_slice($argv, 1))); $self = new self($args['<outfile>']); $self->generatedBy = \join(' ', \array_map('escapeshellarg', $argv)); $self->followSymlinks = $args['--follow-symlinks']; $self->requireMethod = $args['--require-method']; $self->prependAutoload = $args['--prepend']; $self->caseInsensitive = $args['--case-insensitive']; $self->useHack = $args['--hack']; $self->noCache = $args['--no-cache']; if (isset($args['--cache-path'])) { $self->cachePath = $args['--cache-path']; } $files = $self->flattenInputPaths($args['<files>'] ?: array($self->baseDir)); // Remove excluded files $files = \array_diff($files, $self->flattenInputPaths($args['--exclude'])); // Ignore the output file $files = \array_diff($files, array(\realpath($self->outFile))); $scanner = new RealFileScanner(); if (!$self->noCache) { $scanner = CachingFileScanner::create($self->cachePath, $scanner); } foreach ($files as $file) { $parsed = $scanner->scanFile($file); if ($parsed->getConstants() || $parsed->getFunctions()) { $self->eagerFiles[] = $file; } foreach ($parsed->getClasses() as $class) { $self->classMap[$class] = $file; } } $scanner->finish(); print "Writing autoloader to {$self->outFile}\n"; \file_put_contents($self->outFile, $self->generate()); }
public static function putMcData() { $instance = new self(); Session::put('mcData', $instance->generate()); }
public static function transform(\Iterator $it) { $obj = new self($it); return $obj->generate(); }
public static function run() { $engine = new self(); $engine->generate(__DIR__ . '/../../res/amqp-rabbitmq-0.9.1.json', __DIR__ . '/../../src-generated'); }
/** * Returns an instance of the router instantiated * with the optional $routes. * @param array $routes (optional) * @return CallbackRoute */ public static function factory($ctrl, $action) { $router = new self(); return $router->generate($ctrl, $action); }