public function testDataMergeConflict() { $engine = new TwigEngine(new Twig_Environment(), array('package' => 'TwigBridge')); $data = $engine->getData(array('package' => 'bridgetwig', 'username' => 'vivalacrowe')); $this->assertEquals($data['package'], 'bridgetwig'); $this->assertEquals($data['username'], 'vivalacrowe'); }
/** * Compiles all Twig files under path to cache directory. * * @param string $path All twig files under this path are compiled. * @return void */ protected function processPath($path) { $path = realpath($path); $bridge = new TwigBridge($this->laravel); $engine = new TwigEngine($bridge->getTwig()); $finder = new Finder(); $finder->files()->in($path)->name('*.' . $bridge->getExtension()); foreach ($finder as $file) { $full_path = $file->getRealPath(); // Handle files found in sub-folders $view = str_replace($path, '', $full_path); $view = $view[0] === '/' ? substr($view, 1) : $view; $dir = pathinfo($view, PATHINFO_DIRNAME); $dir = $dir !== '.' ? $dir . '/' : ''; $view = $dir . pathinfo($view, PATHINFO_FILENAME); // Let Twig compile the view $engine->load($full_path, $view); $this->count++; } }