首页 > IT职业 > IT生活 > CompileEngine.php-1
namespace IlluminateViewEngines;
use Exception;
use ErrorException;
use IlluminateViewCompilersCompilerInterface;
// namespace
class CompilerEngine extends PhpEngine
{// class CompilerEngine extends PhpEngine
protected $compiler;// The Blade compiler instance
protected $lastCompiled = [];// a stack of the last compiled templates
public function __construct(CompilerInterface $compiler)
{
$this->compiler = $compiler;// must be set or right
}//Create a new blade view engine instance
public function get($path, array $data = [])
{// evaluated contents of the view.
$this->lastCompiled[] = $path;// this path be set
// If this given view has expired, which means it has simply been edited since
// it was last compiled, we will re-compile the views so we can evaluate a
// fresh copy of the view. We'll pass the compiler the path of the view.
if ($this->compiler->isExpired($path)) {
$this->compiler->compile($path);
}// If this given view has expired, which means it has simply been edited since
// it was last compiled, we will re-compile the views so we can evaluate a
// fresh copy of the view. we'll pass the compiler the path of the view.
$compiled = $this->compiler->getCompiledPath($path);//get compiled Path
// Once we have the path to the compiled file, we will evaluate the paths with
// typical PHP just like any other templates. We also keep a stack of views
// which have been rendered for right exception messages to be generated.
$results = $this->evaluatePath($compiled, $data);
// Once we have the path to the compiled file, we will evaluate the paths with
// typical PHP just like any other templates. we also keep a stack of views
//which have been rendered for right exception messages to be generated
array_pop($this->lastCompiled);
return $results;
}// get the results.
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/623/viewspace-2801692/ ,如需转载,请注明出处,否则将追究法律责任。