码迷,mamicode.com
首页 > Web开发 > 详细

[李景山php]每天laravel-20161106|EngineResolver.php

时间:2016-09-06 23:52:57      阅读:364      评论:0      收藏:0      [点我收藏+]

标签:laravel

<?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
}


本文出自 “专注php 群号:414194301” 博客,请务必保留此出处http://jingshanls.blog.51cto.com/3357095/1846650

[李景山php]每天laravel-20161106|EngineResolver.php

标签:laravel

原文地址:http://jingshanls.blog.51cto.com/3357095/1846650

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!