为了账号安全,请及时绑定邮箱和手机立即绑定

CompileEngine.php-1

标签:
PHP

namespace Illuminate\View\Engines;

 

use Exception;

use ErrorException;

use Illuminate\View\Compilers\CompilerInterface;

// namespace

class CompilerEngine extends PhpEngine

{// class CompilerEngine extends PhpEngine

    /**

     * The Blade compiler instance.

     *

     * @var \Illuminate\View\Compilers\CompilerInterface

     */

    protected $compiler;// The Blade compiler instance

 

    /**

     * A stack of the last compiled templates.

     *

     * @var array

     */

    protected $lastCompiled = [];// a stack of the last compiled templates

 

    /**

     * Create a new Blade view engine instance.

     *

     * @param  \Illuminate\View\Compilers\CompilerInterface  $compiler

     * @return void

     */

    public function __construct(CompilerInterface $compiler)

    {

        $this->compiler = $compiler;// must be set or right

    }//Create a new blade view engine instance

 

    /**

     * Get the evaluated contents of the view.

     *

     * @param  string  $path

     * @param  array   $data

     * @return string

     */

    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.

点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消