<?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]每天laravel-20161106|EngineResolver.php
原创
©著作权归作者所有:来自51CTO博客作者lijingsan1的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章