public function testRenderViewWithJson() { $app = new App(vfsStream::url('root/views'), vfsStream::url('root/cache')); $view = $app->renderView('test2'); $this->assertRegExp('/John Mike Doe/', $view); $this->assertRegExp('/mail1@mail.com/', $view); $this->assertRegExp('/mail2@mail.com/', $view); }
protected function execute(InputInterface $input, OutputInterface $output) { $app = new App($this->viewsPath, $this->cachePath); $filesystem = new Filesystem(); $di = new \RecursiveDirectoryIterator($this->viewsPath, \FilesystemIterator::SKIP_DOTS); foreach (new \RecursiveIteratorIterator($di) as $filename => $file) { $filePath = str_replace($this->viewsPath . '/', '', $filename); if (strpos($filePath, '_') === 0 || pathinfo($filename, PATHINFO_EXTENSION) == 'json') { continue; } $view = str_replace('.blade.php', '', $filePath); $pathInfo = pathinfo($view); if ($pathInfo['dirname'] == '.') { $viewDir = '/'; } else { $viewDir = '/' . $pathInfo['dirname'] . '/'; } $dir = $this->outputPath . $viewDir; $filesystem->makeDirectory($dir, 0755, true, true); $filesystem->put($dir . $pathInfo['filename'] . '.html', $app->renderView($view)); } $output->writeln("Done!"); }