public function cacheDirectory($directory)
    {
        $success = 0;
        $errors = 0;
        $errorDetails = [];

        $renderer = $this->getRenderer();
        $events = $renderer->getCompiler()->getEventListeners();

        foreach ($renderer->scanDirectory($directory) as $inputFile) {
            $renderer->initCompiler();
            $compiler = $renderer->getCompiler();
            $compiler->mergeEventListeners($events);
            $path = $inputFile;
            $this->isCacheUpToDate($path);
            $sandBox = $this->getRenderer()->getNewSandBox(function () use (&$success, $compiler, $path, $inputFile) {
                $this->cacheFileContents($path, $compiler->compileFile($inputFile), $compiler->getCurrentImportPaths());
                $success++;
            });
            $error = $sandBox->getThrowable();

            if ($error) {
                $errors++;
                $errorDetails[] = compact(['directory', 'inputFile', 'path', 'error']);
            }
        }

        return [$success, $errors, $errorDetails];
    }
public function cacheDirectory($directory)
    {
        $success = 0;
        $errors = 0;
        $errorDetails = [];

        $renderer = $this->getRenderer();
        $events = $renderer->getCompiler()->getEventListeners();

        foreach ($renderer->scanDirectory($directory) as $inputFile) {
            $renderer->initCompiler();
            $compiler = $renderer->getCompiler();
            $compiler->mergeEventListeners($events);
            $path = $inputFile;
            $this->isCacheUpToDate($path);
            $sandBox = $this->getRenderer()->getNewSandBox(function () use (&$success, $compiler, $path, $inputFile) {
                $this->cacheFileContents($path, $compiler->compileFile($inputFile), $compiler->getCurrentImportPaths());
                $success++;
            });
            $error = $sandBox->getThrowable();

            if ($error) {
                $errors++;
                $errorDetails[] = compact(['directory', 'inputFile', 'path', 'error']);
            }
        }

        return [$success, $errors, $errorDetails];
    }
public function cacheDirectory ( $ directory ) { $ success = 0 ; $ errors = 0 ; $ errorDetails = [ ] ; $ renderer = $ this -> getRenderer ( ) ; $ events = $ renderer -> getCompiler ( ) -> getEventListeners ( ) ; foreach ( $ renderer -> scanDirectory ( $ directory ) as $ inputFile ) { $ renderer -> initCompiler ( ) ; $ compiler = $ renderer -> getCompiler ( ) ; $ compiler -> mergeEventListeners ( $ events ) ; $ path = $ inputFile ; $ this -> isCacheUpToDate ( $ path ) ; $ sandBox = $ this -> getRenderer ( ) -> getNewSandBox ( function ( ) use ( & $ success , $ compiler , $ path , $ inputFile ) { $ this -> cacheFileContents ( $ path , $ compiler -> compileFile ( $ inputFile ) , $ compiler -> getCurrentImportPaths ( ) ) ; $ success ++ ; } ) ; $ error = $ sandBox -> getThrowable ( ) ; if ( $ error ) { $ errors ++ ; $ errorDetails [ ] = compact ( [ 'directory' , 'inputFile' , 'path' , 'error' ] ) ; } } return [ $ success , $ errors , $ errorDetails ] ; }
Scan a directory recursively, compile them and save them into the cache directory.

@param string $directory the directory to search in pug

@throws \Phug\RendererException

@return array count of cached files and error count
Scan a directory recursively compile them and save them into the cache directory .