继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

EngineResolver.php

达令说
关注TA
已关注
手记 334
粉丝 22
获赞 120

<?php

 

namespace Illuminate\View\Engines;

 

use Closure;

use InvalidArgumentException;

 

class EngineResolver

{// engineResolver

    /**

     * The array of engine resolvers.

     *

     * @var array

     */

    protected $resolvers = [];// The array of engine resolvers.

 

    /**

     * The resolved engine instances.

     *

     * @var array

     */

    protected $resolved = [];// The resolved engine instances.

 

    /**

     * Register a new engine resolver.

     *

     * The engine string typically corresponds to a file extension.

     *

     * @param  string   $engine

     * @param  \Closure  $resolver

     * @return void

     */

    public function register($engine, Closure $resolver)

    {

        unset($this->resolved[$engine]);// first to unset it

 

        $this->resolvers[$engine] = $resolver;// set it

    }// Register a new engine resolver.

   // change the new register

 

    /**

     * Resolver an engine instance by name.

     *

     * @param  string  $engine

     * @return \Illuminate\View\Engines\EngineInterface

     * @throws \InvalidArgumentException

     */

    public function resolve($engine)

    {// resolver an engine instance by name.

        if (isset($this->resolved[$engine])) {

            return $this->resolved[$engine];

        }// isset resolved

 

        if (isset($this->resolvers[$engine])) {

            return $this->resolved[$engine] = call_user_func($this->resolvers[$engine]);

        }// isset resolvers

       // call_user_func has been used

 

        throw new InvalidArgumentException("Engine $engine not found.");

    }// throw new exception

}

打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP