update v 1.0.7.5
This commit is contained in:
		
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -1,68 +1,68 @@ | ||||
| <?php namespace Illuminate\View\Compilers; | ||||
| <?php | ||||
|  | ||||
| namespace Illuminate\View\Compilers; | ||||
|  | ||||
| use Illuminate\Filesystem\Filesystem; | ||||
|  | ||||
| abstract class Compiler { | ||||
| abstract class Compiler | ||||
| { | ||||
|     /** | ||||
|      * The Filesystem instance. | ||||
|      * | ||||
|      * @var \Illuminate\Filesystem\Filesystem | ||||
|      */ | ||||
|     protected $files; | ||||
|  | ||||
| 	/** | ||||
| 	 * The Filesystem instance. | ||||
| 	 * | ||||
| 	 * @var \Illuminate\Filesystem\Filesystem | ||||
| 	 */ | ||||
| 	protected $files; | ||||
|     /** | ||||
|      * Get the cache path for the compiled views. | ||||
|      * | ||||
|      * @var string | ||||
|      */ | ||||
|     protected $cachePath; | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the cache path for the compiled views. | ||||
| 	 * | ||||
| 	 * @var string | ||||
| 	 */ | ||||
| 	protected $cachePath; | ||||
|     /** | ||||
|      * Create a new compiler instance. | ||||
|      * | ||||
|      * @param  \Illuminate\Filesystem\Filesystem  $files | ||||
|      * @param  string  $cachePath | ||||
|      * @return void | ||||
|      */ | ||||
|     public function __construct(Filesystem $files, $cachePath) | ||||
|     { | ||||
|         $this->files = $files; | ||||
|         $this->cachePath = $cachePath; | ||||
|     } | ||||
|  | ||||
| 	/** | ||||
| 	 * Create a new compiler instance. | ||||
| 	 * | ||||
| 	 * @param  \Illuminate\Filesystem\Filesystem  $files | ||||
| 	 * @param  string  $cachePath | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	public function __construct(Filesystem $files, $cachePath) | ||||
| 	{ | ||||
| 		$this->files = $files; | ||||
| 		$this->cachePath = $cachePath; | ||||
| 	} | ||||
|     /** | ||||
|      * Get the path to the compiled version of a view. | ||||
|      * | ||||
|      * @param  string  $path | ||||
|      * @return string | ||||
|      */ | ||||
|     public function getCompiledPath($path) | ||||
|     { | ||||
|         return $this->cachePath.'/'.sha1($path).'.php'; | ||||
|     } | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the path to the compiled version of a view. | ||||
| 	 * | ||||
| 	 * @param  string  $path | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	public function getCompiledPath($path) | ||||
| 	{ | ||||
| 		return $this->cachePath.'/'.md5($path); | ||||
| 	} | ||||
|     /** | ||||
|      * Determine if the view at the given path is expired. | ||||
|      * | ||||
|      * @param  string  $path | ||||
|      * @return bool | ||||
|      */ | ||||
|     public function isExpired($path) | ||||
|     { | ||||
|         $compiled = $this->getCompiledPath($path); | ||||
|  | ||||
| 	/** | ||||
| 	 * Determine if the view at the given path is expired. | ||||
| 	 * | ||||
| 	 * @param  string  $path | ||||
| 	 * @return bool | ||||
| 	 */ | ||||
| 	public function isExpired($path) | ||||
| 	{ | ||||
| 		$compiled = $this->getCompiledPath($path); | ||||
|         // If the compiled file doesn't exist we will indicate that the view is expired | ||||
|         // so that it can be re-compiled. Else, we will verify the last modification | ||||
|         // of the views is less than the modification times of the compiled views. | ||||
|         if (! $this->cachePath || ! $this->files->exists($compiled)) { | ||||
|             return true; | ||||
|         } | ||||
|  | ||||
| 		// If the compiled file doesn't exist we will indicate that the view is expired | ||||
| 		// so that it can be re-compiled. Else, we will verify the last modification | ||||
| 		// of the views is less than the modification times of the compiled views. | ||||
| 		if ( ! $this->cachePath || ! $this->files->exists($compiled)) | ||||
| 		{ | ||||
| 			return true; | ||||
| 		} | ||||
|  | ||||
| 		$lastModified = $this->files->lastModified($path); | ||||
|  | ||||
| 		return $lastModified >= $this->files->lastModified($compiled); | ||||
| 	} | ||||
|         $lastModified = $this->files->lastModified($path); | ||||
|  | ||||
|         return $lastModified >= $this->files->lastModified($compiled); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,29 +1,30 @@ | ||||
| <?php namespace Illuminate\View\Compilers; | ||||
| <?php | ||||
|  | ||||
| interface CompilerInterface { | ||||
| namespace Illuminate\View\Compilers; | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the path to the compiled version of a view. | ||||
| 	 * | ||||
| 	 * @param  string  $path | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	public function getCompiledPath($path); | ||||
| interface CompilerInterface | ||||
| { | ||||
|     /** | ||||
|      * Get the path to the compiled version of a view. | ||||
|      * | ||||
|      * @param  string  $path | ||||
|      * @return string | ||||
|      */ | ||||
|     public function getCompiledPath($path); | ||||
|  | ||||
| 	/** | ||||
| 	 * Determine if the given view is expired. | ||||
| 	 * | ||||
| 	 * @param  string  $path | ||||
| 	 * @return bool | ||||
| 	 */ | ||||
| 	public function isExpired($path); | ||||
|  | ||||
| 	/** | ||||
| 	 * Compile the view at the given path. | ||||
| 	 * | ||||
| 	 * @param  string  $path | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	public function compile($path); | ||||
|     /** | ||||
|      * Determine if the given view is expired. | ||||
|      * | ||||
|      * @param  string  $path | ||||
|      * @return bool | ||||
|      */ | ||||
|     public function isExpired($path); | ||||
|  | ||||
|     /** | ||||
|      * Compile the view at the given path. | ||||
|      * | ||||
|      * @param  string  $path | ||||
|      * @return void | ||||
|      */ | ||||
|     public function compile($path); | ||||
| } | ||||
|   | ||||
| @@ -1,101 +1,102 @@ | ||||
| <?php namespace Illuminate\View\Engines; | ||||
| <?php | ||||
|  | ||||
| namespace Illuminate\View\Engines; | ||||
|  | ||||
| use Exception; | ||||
| use ErrorException; | ||||
| use Illuminate\View\Compilers\CompilerInterface; | ||||
|  | ||||
| class CompilerEngine extends PhpEngine { | ||||
| class CompilerEngine extends PhpEngine | ||||
| { | ||||
|     /** | ||||
|      * The Blade compiler instance. | ||||
|      * | ||||
|      * @var \Illuminate\View\Compilers\CompilerInterface | ||||
|      */ | ||||
|     protected $compiler; | ||||
|  | ||||
| 	/** | ||||
| 	 * The Blade compiler instance. | ||||
| 	 * | ||||
| 	 * @var \Illuminate\View\Compilers\CompilerInterface | ||||
| 	 */ | ||||
| 	protected $compiler; | ||||
|     /** | ||||
|      * A stack of the last compiled templates. | ||||
|      * | ||||
|      * @var array | ||||
|      */ | ||||
|     protected $lastCompiled = []; | ||||
|  | ||||
| 	/** | ||||
| 	 * A stack of the last compiled templates. | ||||
| 	 * | ||||
| 	 * @var array | ||||
| 	 */ | ||||
| 	protected $lastCompiled = array(); | ||||
|     /** | ||||
|      * Create a new Blade view engine instance. | ||||
|      * | ||||
|      * @param  \Illuminate\View\Compilers\CompilerInterface  $compiler | ||||
|      * @return void | ||||
|      */ | ||||
|     public function __construct(CompilerInterface $compiler) | ||||
|     { | ||||
|         $this->compiler = $compiler; | ||||
|     } | ||||
|  | ||||
| 	/** | ||||
| 	 * Create a new Blade view engine instance. | ||||
| 	 * | ||||
| 	 * @param  \Illuminate\View\Compilers\CompilerInterface  $compiler | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	public function __construct(CompilerInterface $compiler) | ||||
| 	{ | ||||
| 		$this->compiler = $compiler; | ||||
| 	} | ||||
|     /** | ||||
|      * Get the evaluated contents of the view. | ||||
|      * | ||||
|      * @param  string  $path | ||||
|      * @param  array   $data | ||||
|      * @return string | ||||
|      */ | ||||
|     public function get($path, array $data = []) | ||||
|     { | ||||
|         $this->lastCompiled[] = $path; | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the evaluated contents of the view. | ||||
| 	 * | ||||
| 	 * @param  string  $path | ||||
| 	 * @param  array   $data | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	public function get($path, array $data = array()) | ||||
| 	{ | ||||
| 		$this->lastCompiled[] = $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. | ||||
|         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. | ||||
| 		if ($this->compiler->isExpired($path)) | ||||
| 		{ | ||||
| 			$this->compiler->compile($path); | ||||
| 		} | ||||
|         $compiled = $this->compiler->getCompiledPath($path); | ||||
|  | ||||
| 		$compiled = $this->compiler->getCompiledPath($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. | ||||
| 		$results = $this->evaluatePath($compiled, $data); | ||||
|         array_pop($this->lastCompiled); | ||||
|  | ||||
| 		array_pop($this->lastCompiled); | ||||
|         return $results; | ||||
|     } | ||||
|  | ||||
| 		return $results; | ||||
| 	} | ||||
|     /** | ||||
|      * Handle a view exception. | ||||
|      * | ||||
|      * @param  \Exception  $e | ||||
|      * @param  int  $obLevel | ||||
|      * @return void | ||||
|      * | ||||
|      * @throws $e | ||||
|      */ | ||||
|     protected function handleViewException(Exception $e, $obLevel) | ||||
|     { | ||||
|         $e = new ErrorException($this->getMessage($e), 0, 1, $e->getFile(), $e->getLine(), $e); | ||||
|  | ||||
| 	/** | ||||
| 	 * Handle a view exception. | ||||
| 	 * | ||||
| 	 * @param  \Exception  $e | ||||
| 	 * @param  int  $obLevel | ||||
| 	 * @return void | ||||
| 	 * | ||||
| 	 * @throws $e | ||||
| 	 */ | ||||
| 	protected function handleViewException($e, $obLevel) | ||||
| 	{ | ||||
| 		$e = new ErrorException($this->getMessage($e), 0, 1, $e->getFile(), $e->getLine(), $e); | ||||
|         parent::handleViewException($e, $obLevel); | ||||
|     } | ||||
|  | ||||
| 		parent::handleViewException($e, $obLevel); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the exception message for an exception. | ||||
| 	 * | ||||
| 	 * @param  \Exception  $e | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	protected function getMessage($e) | ||||
| 	{ | ||||
| 		return $e->getMessage().' (View: '.realpath(last($this->lastCompiled)).')'; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the compiler implementation. | ||||
| 	 * | ||||
| 	 * @return \Illuminate\View\Compilers\CompilerInterface | ||||
| 	 */ | ||||
| 	public function getCompiler() | ||||
| 	{ | ||||
| 		return $this->compiler; | ||||
| 	} | ||||
|     /** | ||||
|      * Get the exception message for an exception. | ||||
|      * | ||||
|      * @param  \Exception  $e | ||||
|      * @return string | ||||
|      */ | ||||
|     protected function getMessage(Exception $e) | ||||
|     { | ||||
|         return $e->getMessage().' (View: '.realpath(last($this->lastCompiled)).')'; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Get the compiler implementation. | ||||
|      * | ||||
|      * @return \Illuminate\View\Compilers\CompilerInterface | ||||
|      */ | ||||
|     public function getCompiler() | ||||
|     { | ||||
|         return $this->compiler; | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,22 +1,23 @@ | ||||
| <?php namespace Illuminate\View\Engines; | ||||
| <?php | ||||
|  | ||||
| abstract class Engine { | ||||
| namespace Illuminate\View\Engines; | ||||
|  | ||||
| 	/** | ||||
| 	 * The view that was last to be rendered. | ||||
| 	 * | ||||
| 	 * @var string | ||||
| 	 */ | ||||
| 	protected $lastRendered; | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the last view that was rendered. | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	public function getLastRendered() | ||||
| 	{ | ||||
| 		return $this->lastRendered; | ||||
| 	} | ||||
| abstract class Engine | ||||
| { | ||||
|     /** | ||||
|      * The view that was last to be rendered. | ||||
|      * | ||||
|      * @var string | ||||
|      */ | ||||
|     protected $lastRendered; | ||||
|  | ||||
|     /** | ||||
|      * Get the last view that was rendered. | ||||
|      * | ||||
|      * @return string | ||||
|      */ | ||||
|     public function getLastRendered() | ||||
|     { | ||||
|         return $this->lastRendered; | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,14 +1,15 @@ | ||||
| <?php namespace Illuminate\View\Engines; | ||||
| <?php | ||||
|  | ||||
| interface EngineInterface { | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the evaluated contents of the view. | ||||
| 	 * | ||||
| 	 * @param  string  $path | ||||
| 	 * @param  array   $data | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	public function get($path, array $data = array()); | ||||
| namespace Illuminate\View\Engines; | ||||
|  | ||||
| interface EngineInterface | ||||
| { | ||||
|     /** | ||||
|      * Get the evaluated contents of the view. | ||||
|      * | ||||
|      * @param  string  $path | ||||
|      * @param  array   $data | ||||
|      * @return string | ||||
|      */ | ||||
|     public function get($path, array $data = []); | ||||
| } | ||||
|   | ||||
| @@ -1,60 +1,59 @@ | ||||
| <?php namespace Illuminate\View\Engines; | ||||
| <?php | ||||
|  | ||||
| namespace Illuminate\View\Engines; | ||||
|  | ||||
| use Closure; | ||||
| use InvalidArgumentException; | ||||
|  | ||||
| class EngineResolver { | ||||
| class EngineResolver | ||||
| { | ||||
|     /** | ||||
|      * The array of engine resolvers. | ||||
|      * | ||||
|      * @var array | ||||
|      */ | ||||
|     protected $resolvers = []; | ||||
|  | ||||
| 	/** | ||||
| 	 * The array of engine resolvers. | ||||
| 	 * | ||||
| 	 * @var array | ||||
| 	 */ | ||||
| 	protected $resolvers = array(); | ||||
|     /** | ||||
|      * The resolved engine instances. | ||||
|      * | ||||
|      * @var array | ||||
|      */ | ||||
|     protected $resolved = []; | ||||
|  | ||||
| 	/** | ||||
| 	 * The resolved engine instances. | ||||
| 	 * | ||||
| 	 * @var array | ||||
| 	 */ | ||||
| 	protected $resolved = array(); | ||||
|     /** | ||||
|      * 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]); | ||||
|  | ||||
| 	/** | ||||
| 	 * 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]); | ||||
|         $this->resolvers[$engine] = $resolver; | ||||
|     } | ||||
|  | ||||
| 		$this->resolvers[$engine] = $resolver; | ||||
| 	} | ||||
|     /** | ||||
|      * Resolver an engine instance by name. | ||||
|      * | ||||
|      * @param  string  $engine | ||||
|      * @return \Illuminate\View\Engines\EngineInterface | ||||
|      * @throws \InvalidArgumentException | ||||
|      */ | ||||
|     public function resolve($engine) | ||||
|     { | ||||
|         if (isset($this->resolved[$engine])) { | ||||
|             return $this->resolved[$engine]; | ||||
|         } | ||||
|  | ||||
| 	/** | ||||
| 	 * Resolver an engine instance by name. | ||||
| 	 * | ||||
| 	 * @param  string  $engine | ||||
| 	 * @return \Illuminate\View\Engines\EngineInterface | ||||
| 	 * @throws \InvalidArgumentException | ||||
| 	 */ | ||||
| 	public function resolve($engine) | ||||
| 	{ | ||||
| 		if (isset($this->resolved[$engine])) | ||||
| 		{ | ||||
| 			return $this->resolved[$engine]; | ||||
| 		} | ||||
|  | ||||
| 		if (isset($this->resolvers[$engine])) | ||||
| 		{ | ||||
| 			return $this->resolved[$engine] = call_user_func($this->resolvers[$engine]); | ||||
| 		} | ||||
|  | ||||
| 		throw new InvalidArgumentException("Engine $engine not found."); | ||||
| 	} | ||||
|         if (isset($this->resolvers[$engine])) { | ||||
|             return $this->resolved[$engine] = call_user_func($this->resolvers[$engine]); | ||||
|         } | ||||
|  | ||||
|         throw new InvalidArgumentException("Engine $engine not found."); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,68 +1,69 @@ | ||||
| <?php namespace Illuminate\View\Engines; | ||||
| <?php | ||||
|  | ||||
| namespace Illuminate\View\Engines; | ||||
|  | ||||
| use Exception; | ||||
| use Throwable; | ||||
| use Symfony\Component\Debug\Exception\FatalThrowableError; | ||||
|  | ||||
| class PhpEngine implements EngineInterface { | ||||
| class PhpEngine implements EngineInterface | ||||
| { | ||||
|     /** | ||||
|      * Get the evaluated contents of the view. | ||||
|      * | ||||
|      * @param  string  $path | ||||
|      * @param  array   $data | ||||
|      * @return string | ||||
|      */ | ||||
|     public function get($path, array $data = []) | ||||
|     { | ||||
|         return $this->evaluatePath($path, $data); | ||||
|     } | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the evaluated contents of the view. | ||||
| 	 * | ||||
| 	 * @param  string  $path | ||||
| 	 * @param  array   $data | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	public function get($path, array $data = array()) | ||||
| 	{ | ||||
| 		return $this->evaluatePath($path, $data); | ||||
| 	} | ||||
|     /** | ||||
|      * Get the evaluated contents of the view at the given path. | ||||
|      * | ||||
|      * @param  string  $__path | ||||
|      * @param  array   $__data | ||||
|      * @return string | ||||
|      */ | ||||
|     protected function evaluatePath($__path, $__data) | ||||
|     { | ||||
|         $obLevel = ob_get_level(); | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the evaluated contents of the view at the given path. | ||||
| 	 * | ||||
| 	 * @param  string  $__path | ||||
| 	 * @param  array   $__data | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	protected function evaluatePath($__path, $__data) | ||||
| 	{ | ||||
| 		$obLevel = ob_get_level(); | ||||
|         ob_start(); | ||||
|  | ||||
| 		ob_start(); | ||||
|         extract($__data, EXTR_SKIP); | ||||
|  | ||||
| 		extract($__data); | ||||
|         // We'll evaluate the contents of the view inside a try/catch block so we can | ||||
|         // flush out any stray output that might get out before an error occurs or | ||||
|         // an exception is thrown. This prevents any partial views from leaking. | ||||
|         try { | ||||
|             include $__path; | ||||
|         } catch (Exception $e) { | ||||
|             $this->handleViewException($e, $obLevel); | ||||
|         } catch (Throwable $e) { | ||||
|             $this->handleViewException(new FatalThrowableError($e), $obLevel); | ||||
|         } | ||||
|  | ||||
| 		// We'll evaluate the contents of the view inside a try/catch block so we can | ||||
| 		// flush out any stray output that might get out before an error occurs or | ||||
| 		// an exception is thrown. This prevents any partial views from leaking. | ||||
| 		try | ||||
| 		{ | ||||
| 			include $__path; | ||||
| 		} | ||||
| 		catch (Exception $e) | ||||
| 		{ | ||||
| 			$this->handleViewException($e, $obLevel); | ||||
| 		} | ||||
|         return ltrim(ob_get_clean()); | ||||
|     } | ||||
|  | ||||
| 		return ltrim(ob_get_clean()); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Handle a view exception. | ||||
| 	 * | ||||
| 	 * @param  \Exception  $e | ||||
| 	 * @param  int  $obLevel | ||||
| 	 * @return void | ||||
| 	 * | ||||
| 	 * @throws $e | ||||
| 	 */ | ||||
| 	protected function handleViewException($e, $obLevel) | ||||
| 	{ | ||||
| 		while (ob_get_level() > $obLevel) | ||||
| 		{ | ||||
| 			ob_end_clean(); | ||||
| 		} | ||||
|  | ||||
| 		throw $e; | ||||
| 	} | ||||
|     /** | ||||
|      * Handle a view exception. | ||||
|      * | ||||
|      * @param  \Exception  $e | ||||
|      * @param  int  $obLevel | ||||
|      * @return void | ||||
|      * | ||||
|      * @throws $e | ||||
|      */ | ||||
|     protected function handleViewException(Exception $e, $obLevel) | ||||
|     { | ||||
|         while (ob_get_level() > $obLevel) { | ||||
|             ob_end_clean(); | ||||
|         } | ||||
|  | ||||
|         throw $e; | ||||
|     } | ||||
| } | ||||
|   | ||||
							
								
								
									
										12
									
								
								vendor/laravel/framework/src/Illuminate/View/Expression.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								vendor/laravel/framework/src/Illuminate/View/Expression.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,12 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Illuminate\View; | ||||
|  | ||||
| use Illuminate\Support\HtmlString; | ||||
|  | ||||
| /** | ||||
|  * @deprecated since version 5.2. Use Illuminate\Support\HtmlString. | ||||
|  */ | ||||
| class Expression extends HtmlString | ||||
| { | ||||
| } | ||||
							
								
								
									
										1855
									
								
								vendor/laravel/framework/src/Illuminate/View/Factory.php
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1855
									
								
								vendor/laravel/framework/src/Illuminate/View/Factory.php
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -1,274 +1,265 @@ | ||||
| <?php namespace Illuminate\View; | ||||
| <?php | ||||
|  | ||||
| namespace Illuminate\View; | ||||
|  | ||||
| use InvalidArgumentException; | ||||
| use Illuminate\Filesystem\Filesystem; | ||||
|  | ||||
| class FileViewFinder implements ViewFinderInterface { | ||||
| class FileViewFinder implements ViewFinderInterface | ||||
| { | ||||
|     /** | ||||
|      * The filesystem instance. | ||||
|      * | ||||
|      * @var \Illuminate\Filesystem\Filesystem | ||||
|      */ | ||||
|     protected $files; | ||||
|  | ||||
| 	/** | ||||
| 	 * The filesystem instance. | ||||
| 	 * | ||||
| 	 * @var \Illuminate\Filesystem\Filesystem | ||||
| 	 */ | ||||
| 	protected $files; | ||||
|     /** | ||||
|      * The array of active view paths. | ||||
|      * | ||||
|      * @var array | ||||
|      */ | ||||
|     protected $paths; | ||||
|  | ||||
| 	/** | ||||
| 	 * The array of active view paths. | ||||
| 	 * | ||||
| 	 * @var array | ||||
| 	 */ | ||||
| 	protected $paths; | ||||
|     /** | ||||
|      * The array of views that have been located. | ||||
|      * | ||||
|      * @var array | ||||
|      */ | ||||
|     protected $views = []; | ||||
|  | ||||
| 	/** | ||||
| 	 * The array of views that have been located. | ||||
| 	 * | ||||
| 	 * @var array | ||||
| 	 */ | ||||
| 	protected $views = array(); | ||||
|     /** | ||||
|      * The namespace to file path hints. | ||||
|      * | ||||
|      * @var array | ||||
|      */ | ||||
|     protected $hints = []; | ||||
|  | ||||
| 	/** | ||||
| 	 * The namespace to file path hints. | ||||
| 	 * | ||||
| 	 * @var array | ||||
| 	 */ | ||||
| 	protected $hints = array(); | ||||
|     /** | ||||
|      * Register a view extension with the finder. | ||||
|      * | ||||
|      * @var array | ||||
|      */ | ||||
|     protected $extensions = ['blade.php', 'php']; | ||||
|  | ||||
| 	/** | ||||
| 	 * Register a view extension with the finder. | ||||
| 	 * | ||||
| 	 * @var array | ||||
| 	 */ | ||||
| 	protected $extensions = array('blade.php', 'php'); | ||||
|     /** | ||||
|      * Create a new file view loader instance. | ||||
|      * | ||||
|      * @param  \Illuminate\Filesystem\Filesystem  $files | ||||
|      * @param  array  $paths | ||||
|      * @param  array  $extensions | ||||
|      * @return void | ||||
|      */ | ||||
|     public function __construct(Filesystem $files, array $paths, array $extensions = null) | ||||
|     { | ||||
|         $this->files = $files; | ||||
|         $this->paths = $paths; | ||||
|  | ||||
| 	/** | ||||
| 	 * Create a new file view loader instance. | ||||
| 	 * | ||||
| 	 * @param  \Illuminate\Filesystem\Filesystem  $files | ||||
| 	 * @param  array  $paths | ||||
| 	 * @param  array  $extensions | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	public function __construct(Filesystem $files, array $paths, array $extensions = null) | ||||
| 	{ | ||||
| 		$this->files = $files; | ||||
| 		$this->paths = $paths; | ||||
|         if (isset($extensions)) { | ||||
|             $this->extensions = $extensions; | ||||
|         } | ||||
|     } | ||||
|  | ||||
| 		if (isset($extensions)) | ||||
| 		{ | ||||
| 			$this->extensions = $extensions; | ||||
| 		} | ||||
| 	} | ||||
|     /** | ||||
|      * Get the fully qualified location of the view. | ||||
|      * | ||||
|      * @param  string  $name | ||||
|      * @return string | ||||
|      */ | ||||
|     public function find($name) | ||||
|     { | ||||
|         if (isset($this->views[$name])) { | ||||
|             return $this->views[$name]; | ||||
|         } | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the fully qualified location of the view. | ||||
| 	 * | ||||
| 	 * @param  string  $name | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	public function find($name) | ||||
| 	{ | ||||
| 		if (isset($this->views[$name])) return $this->views[$name]; | ||||
|         if ($this->hasHintInformation($name = trim($name))) { | ||||
|             return $this->views[$name] = $this->findNamedPathView($name); | ||||
|         } | ||||
|  | ||||
| 		if ($this->hasHintInformation($name = trim($name))) | ||||
| 		{ | ||||
| 			return $this->views[$name] = $this->findNamedPathView($name); | ||||
| 		} | ||||
|         return $this->views[$name] = $this->findInPaths($name, $this->paths); | ||||
|     } | ||||
|  | ||||
| 		return $this->views[$name] = $this->findInPaths($name, $this->paths); | ||||
| 	} | ||||
|     /** | ||||
|      * Get the path to a template with a named path. | ||||
|      * | ||||
|      * @param  string  $name | ||||
|      * @return string | ||||
|      */ | ||||
|     protected function findNamedPathView($name) | ||||
|     { | ||||
|         list($namespace, $view) = $this->getNamespaceSegments($name); | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the path to a template with a named path. | ||||
| 	 * | ||||
| 	 * @param  string  $name | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	protected function findNamedPathView($name) | ||||
| 	{ | ||||
| 		list($namespace, $view) = $this->getNamespaceSegments($name); | ||||
|         return $this->findInPaths($view, $this->hints[$namespace]); | ||||
|     } | ||||
|  | ||||
| 		return $this->findInPaths($view, $this->hints[$namespace]); | ||||
| 	} | ||||
|     /** | ||||
|      * Get the segments of a template with a named path. | ||||
|      * | ||||
|      * @param  string  $name | ||||
|      * @return array | ||||
|      * | ||||
|      * @throws \InvalidArgumentException | ||||
|      */ | ||||
|     protected function getNamespaceSegments($name) | ||||
|     { | ||||
|         $segments = explode(static::HINT_PATH_DELIMITER, $name); | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the segments of a template with a named path. | ||||
| 	 * | ||||
| 	 * @param  string  $name | ||||
| 	 * @return array | ||||
| 	 * | ||||
| 	 * @throws \InvalidArgumentException | ||||
| 	 */ | ||||
| 	protected function getNamespaceSegments($name) | ||||
| 	{ | ||||
| 		$segments = explode(static::HINT_PATH_DELIMITER, $name); | ||||
|         if (count($segments) != 2) { | ||||
|             throw new InvalidArgumentException("View [$name] has an invalid name."); | ||||
|         } | ||||
|  | ||||
| 		if (count($segments) != 2) | ||||
| 		{ | ||||
| 			throw new InvalidArgumentException("View [$name] has an invalid name."); | ||||
| 		} | ||||
|         if (! isset($this->hints[$segments[0]])) { | ||||
|             throw new InvalidArgumentException("No hint path defined for [{$segments[0]}]."); | ||||
|         } | ||||
|  | ||||
| 		if ( ! isset($this->hints[$segments[0]])) | ||||
| 		{ | ||||
| 			throw new InvalidArgumentException("No hint path defined for [{$segments[0]}]."); | ||||
| 		} | ||||
|         return $segments; | ||||
|     } | ||||
|  | ||||
| 		return $segments; | ||||
| 	} | ||||
|     /** | ||||
|      * Find the given view in the list of paths. | ||||
|      * | ||||
|      * @param  string  $name | ||||
|      * @param  array   $paths | ||||
|      * @return string | ||||
|      * | ||||
|      * @throws \InvalidArgumentException | ||||
|      */ | ||||
|     protected function findInPaths($name, $paths) | ||||
|     { | ||||
|         foreach ((array) $paths as $path) { | ||||
|             foreach ($this->getPossibleViewFiles($name) as $file) { | ||||
|                 if ($this->files->exists($viewPath = $path.'/'.$file)) { | ||||
|                     return $viewPath; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
| 	/** | ||||
| 	 * Find the given view in the list of paths. | ||||
| 	 * | ||||
| 	 * @param  string  $name | ||||
| 	 * @param  array   $paths | ||||
| 	 * @return string | ||||
| 	 * | ||||
| 	 * @throws \InvalidArgumentException | ||||
| 	 */ | ||||
| 	protected function findInPaths($name, $paths) | ||||
| 	{ | ||||
| 		foreach ((array) $paths as $path) | ||||
| 		{ | ||||
| 			foreach ($this->getPossibleViewFiles($name) as $file) | ||||
| 			{ | ||||
| 				if ($this->files->exists($viewPath = $path.'/'.$file)) | ||||
| 				{ | ||||
| 					return $viewPath; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|         throw new InvalidArgumentException("View [$name] not found."); | ||||
|     } | ||||
|  | ||||
| 		throw new InvalidArgumentException("View [$name] not found."); | ||||
| 	} | ||||
|     /** | ||||
|      * Get an array of possible view files. | ||||
|      * | ||||
|      * @param  string  $name | ||||
|      * @return array | ||||
|      */ | ||||
|     protected function getPossibleViewFiles($name) | ||||
|     { | ||||
|         return array_map(function ($extension) use ($name) { | ||||
|             return str_replace('.', '/', $name).'.'.$extension; | ||||
|         }, $this->extensions); | ||||
|     } | ||||
|  | ||||
| 	/** | ||||
| 	 * Get an array of possible view files. | ||||
| 	 * | ||||
| 	 * @param  string  $name | ||||
| 	 * @return array | ||||
| 	 */ | ||||
| 	protected function getPossibleViewFiles($name) | ||||
| 	{ | ||||
| 		return array_map(function($extension) use ($name) | ||||
| 		{ | ||||
| 			return str_replace('.', '/', $name).'.'.$extension; | ||||
|     /** | ||||
|      * Add a location to the finder. | ||||
|      * | ||||
|      * @param  string  $location | ||||
|      * @return void | ||||
|      */ | ||||
|     public function addLocation($location) | ||||
|     { | ||||
|         $this->paths[] = $location; | ||||
|     } | ||||
|  | ||||
| 		}, $this->extensions); | ||||
| 	} | ||||
|     /** | ||||
|      * Add a namespace hint to the finder. | ||||
|      * | ||||
|      * @param  string  $namespace | ||||
|      * @param  string|array  $hints | ||||
|      * @return void | ||||
|      */ | ||||
|     public function addNamespace($namespace, $hints) | ||||
|     { | ||||
|         $hints = (array) $hints; | ||||
|  | ||||
| 	/** | ||||
| 	 * Add a location to the finder. | ||||
| 	 * | ||||
| 	 * @param  string  $location | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	public function addLocation($location) | ||||
| 	{ | ||||
| 		$this->paths[] = $location; | ||||
| 	} | ||||
|         if (isset($this->hints[$namespace])) { | ||||
|             $hints = array_merge($this->hints[$namespace], $hints); | ||||
|         } | ||||
|  | ||||
| 	/** | ||||
| 	 * Add a namespace hint to the finder. | ||||
| 	 * | ||||
| 	 * @param  string  $namespace | ||||
| 	 * @param  string|array  $hints | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	public function addNamespace($namespace, $hints) | ||||
| 	{ | ||||
| 		$hints = (array) $hints; | ||||
|         $this->hints[$namespace] = $hints; | ||||
|     } | ||||
|  | ||||
| 		if (isset($this->hints[$namespace])) | ||||
| 		{ | ||||
| 			$hints = array_merge($this->hints[$namespace], $hints); | ||||
| 		} | ||||
|     /** | ||||
|      * Prepend a namespace hint to the finder. | ||||
|      * | ||||
|      * @param  string  $namespace | ||||
|      * @param  string|array  $hints | ||||
|      * @return void | ||||
|      */ | ||||
|     public function prependNamespace($namespace, $hints) | ||||
|     { | ||||
|         $hints = (array) $hints; | ||||
|  | ||||
| 		$this->hints[$namespace] = $hints; | ||||
| 	} | ||||
|         if (isset($this->hints[$namespace])) { | ||||
|             $hints = array_merge($hints, $this->hints[$namespace]); | ||||
|         } | ||||
|  | ||||
| 	/** | ||||
| 	 * Prepend a namespace hint to the finder. | ||||
| 	 * | ||||
| 	 * @param  string  $namespace | ||||
| 	 * @param  string|array  $hints | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	public function prependNamespace($namespace, $hints) | ||||
| 	{ | ||||
| 		$hints = (array) $hints; | ||||
|         $this->hints[$namespace] = $hints; | ||||
|     } | ||||
|  | ||||
| 		if (isset($this->hints[$namespace])) | ||||
| 		{ | ||||
| 			$hints = array_merge($hints, $this->hints[$namespace]); | ||||
| 		} | ||||
|     /** | ||||
|      * Register an extension with the view finder. | ||||
|      * | ||||
|      * @param  string  $extension | ||||
|      * @return void | ||||
|      */ | ||||
|     public function addExtension($extension) | ||||
|     { | ||||
|         if (($index = array_search($extension, $this->extensions)) !== false) { | ||||
|             unset($this->extensions[$index]); | ||||
|         } | ||||
|  | ||||
| 		$this->hints[$namespace] = $hints; | ||||
| 	} | ||||
|         array_unshift($this->extensions, $extension); | ||||
|     } | ||||
|  | ||||
| 	/** | ||||
| 	 * Register an extension with the view finder. | ||||
| 	 * | ||||
| 	 * @param  string  $extension | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	public function addExtension($extension) | ||||
| 	{ | ||||
| 		if (($index = array_search($extension, $this->extensions)) !== false) | ||||
| 		{ | ||||
| 			unset($this->extensions[$index]); | ||||
| 		} | ||||
|     /** | ||||
|      * Returns whether or not the view specify a hint information. | ||||
|      * | ||||
|      * @param  string  $name | ||||
|      * @return bool | ||||
|      */ | ||||
|     public function hasHintInformation($name) | ||||
|     { | ||||
|         return strpos($name, static::HINT_PATH_DELIMITER) > 0; | ||||
|     } | ||||
|  | ||||
| 		array_unshift($this->extensions, $extension); | ||||
| 	} | ||||
|     /** | ||||
|      * Get the filesystem instance. | ||||
|      * | ||||
|      * @return \Illuminate\Filesystem\Filesystem | ||||
|      */ | ||||
|     public function getFilesystem() | ||||
|     { | ||||
|         return $this->files; | ||||
|     } | ||||
|  | ||||
| 	/** | ||||
| 	 * Returns whether or not the view specify a hint information. | ||||
| 	 * | ||||
| 	 * @param  string  $name | ||||
| 	 * @return bool | ||||
| 	 */ | ||||
| 	public function hasHintInformation($name) | ||||
| 	{ | ||||
| 		return strpos($name, static::HINT_PATH_DELIMITER) > 0; | ||||
| 	} | ||||
|     /** | ||||
|      * Get the active view paths. | ||||
|      * | ||||
|      * @return array | ||||
|      */ | ||||
|     public function getPaths() | ||||
|     { | ||||
|         return $this->paths; | ||||
|     } | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the filesystem instance. | ||||
| 	 * | ||||
| 	 * @return \Illuminate\Filesystem\Filesystem | ||||
| 	 */ | ||||
| 	public function getFilesystem() | ||||
| 	{ | ||||
| 		return $this->files; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the active view paths. | ||||
| 	 * | ||||
| 	 * @return array | ||||
| 	 */ | ||||
| 	public function getPaths() | ||||
| 	{ | ||||
| 		return $this->paths; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the namespace to file path hints. | ||||
| 	 * | ||||
| 	 * @return array | ||||
| 	 */ | ||||
| 	public function getHints() | ||||
| 	{ | ||||
| 		return $this->hints; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get registered extensions. | ||||
| 	 * | ||||
| 	 * @return array | ||||
| 	 */ | ||||
| 	public function getExtensions() | ||||
| 	{ | ||||
| 		return $this->extensions; | ||||
| 	} | ||||
|     /** | ||||
|      * Get the namespace to file path hints. | ||||
|      * | ||||
|      * @return array | ||||
|      */ | ||||
|     public function getHints() | ||||
|     { | ||||
|         return $this->hints; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Get registered extensions. | ||||
|      * | ||||
|      * @return array | ||||
|      */ | ||||
|     public function getExtensions() | ||||
|     { | ||||
|         return $this->extensions; | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,58 +1,51 @@ | ||||
| <?php namespace Illuminate\View\Middleware; | ||||
| <?php | ||||
|  | ||||
| namespace Illuminate\View\Middleware; | ||||
|  | ||||
| use Closure; | ||||
| use Illuminate\Support\ViewErrorBag; | ||||
| use Illuminate\Contracts\Routing\Middleware; | ||||
| use Illuminate\Contracts\View\Factory as ViewFactory; | ||||
|  | ||||
| class ShareErrorsFromSession implements Middleware { | ||||
| class ShareErrorsFromSession | ||||
| { | ||||
|     /** | ||||
|      * The view factory implementation. | ||||
|      * | ||||
|      * @var \Illuminate\Contracts\View\Factory | ||||
|      */ | ||||
|     protected $view; | ||||
|  | ||||
| 	/** | ||||
| 	 * The view factory implementation. | ||||
| 	 * | ||||
| 	 * @var \Illuminate\Contracts\View\Factory | ||||
| 	 */ | ||||
| 	protected $view; | ||||
|     /** | ||||
|      * Create a new error binder instance. | ||||
|      * | ||||
|      * @param  \Illuminate\Contracts\View\Factory  $view | ||||
|      * @return void | ||||
|      */ | ||||
|     public function __construct(ViewFactory $view) | ||||
|     { | ||||
|         $this->view = $view; | ||||
|     } | ||||
|  | ||||
| 	/** | ||||
| 	 * Create a new error binder instance. | ||||
| 	 * | ||||
| 	 * @param  \Illuminate\Contracts\View\Factory  $view | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	public function __construct(ViewFactory $view) | ||||
| 	{ | ||||
| 		$this->view = $view; | ||||
| 	} | ||||
|     /** | ||||
|      * Handle an incoming request. | ||||
|      * | ||||
|      * @param  \Illuminate\Http\Request  $request | ||||
|      * @param  \Closure  $next | ||||
|      * @return mixed | ||||
|      */ | ||||
|     public function handle($request, Closure $next) | ||||
|     { | ||||
|         // If the current session has an "errors" variable bound to it, we will share | ||||
|         // its value with all view instances so the views can easily access errors | ||||
|         // without having to bind. An empty bag is set when there aren't errors. | ||||
|         $this->view->share( | ||||
|             'errors', $request->session()->get('errors') ?: new ViewErrorBag | ||||
|         ); | ||||
|  | ||||
| 	/** | ||||
| 	 * Handle an incoming request. | ||||
| 	 * | ||||
| 	 * @param  \Illuminate\Http\Request  $request | ||||
| 	 * @param  \Closure  $next | ||||
| 	 * @return mixed | ||||
| 	 */ | ||||
| 	public function handle($request, Closure $next) | ||||
| 	{ | ||||
| 		// If the current session has an "errors" variable bound to it, we will share | ||||
| 		// its value with all view instances so the views can easily access errors | ||||
| 		// without having to bind. An empty bag is set when there aren't errors. | ||||
| 		if ($request->session()->has('errors')) | ||||
| 		{ | ||||
| 			$this->view->share( | ||||
| 				'errors', $request->session()->get('errors') | ||||
| 			); | ||||
| 		} | ||||
|  | ||||
| 		// Putting the errors in the view for every view allows the developer to just | ||||
| 		// assume that some errors are always available, which is convenient since | ||||
| 		// they don't have to continually run checks for the presence of errors. | ||||
| 		else | ||||
| 		{ | ||||
| 			$this->view->share('errors', new ViewErrorBag); | ||||
| 		} | ||||
|  | ||||
| 		return $next($request); | ||||
| 	} | ||||
|         // Putting the errors in the view for every view allows the developer to just | ||||
|         // assume that some errors are always available, which is convenient since | ||||
|         // they don't have to continually run checks for the presence of errors. | ||||
|  | ||||
|         return $next($request); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,8 +1,12 @@ | ||||
| <?php namespace Illuminate\View; | ||||
| <?php | ||||
|  | ||||
| use Closure; | ||||
| namespace Illuminate\View; | ||||
|  | ||||
| use Exception; | ||||
| use Throwable; | ||||
| use ArrayAccess; | ||||
| use BadMethodCallException; | ||||
| use Illuminate\Support\Str; | ||||
| use Illuminate\Support\MessageBag; | ||||
| use Illuminate\Contracts\Support\Arrayable; | ||||
| use Illuminate\View\Engines\EngineInterface; | ||||
| @@ -12,7 +16,6 @@ use Illuminate\Contracts\View\View as ViewContract; | ||||
|  | ||||
| class View implements ArrayAccess, ViewContract | ||||
| { | ||||
|  | ||||
|     /** | ||||
|      * The view factory instance. | ||||
|      * | ||||
| @@ -55,10 +58,10 @@ class View implements ArrayAccess, ViewContract | ||||
|      * @param  \Illuminate\View\Engines\EngineInterface  $engine | ||||
|      * @param  string  $view | ||||
|      * @param  string  $path | ||||
|      * @param  array   $data | ||||
|      * @param  mixed  $data | ||||
|      * @return void | ||||
|      */ | ||||
|     public function __construct(Factory $factory, EngineInterface $engine, $view, $path, $data = array()) | ||||
|     public function __construct(Factory $factory, EngineInterface $engine, $view, $path, $data = []) | ||||
|     { | ||||
|         $this->view = $view; | ||||
|         $this->path = $path; | ||||
| @@ -71,25 +74,31 @@ class View implements ArrayAccess, ViewContract | ||||
|     /** | ||||
|      * Get the string contents of the view. | ||||
|      * | ||||
|      * @param  \Closure|null  $callback | ||||
|      * @param  callable|null  $callback | ||||
|      * @return string | ||||
|      * | ||||
|      * @throws \Throwable | ||||
|      */ | ||||
|     public function render(Closure $callback = null) | ||||
|     public function render(callable $callback = null) | ||||
|     { | ||||
|         try { | ||||
|             $contents = $this->renderContents(); | ||||
|  | ||||
|             $response = isset($callback) ? $callback($this, $contents) : null; | ||||
|             $response = isset($callback) ? call_user_func($callback, $this, $contents) : null; | ||||
|  | ||||
|             // Once we have the contents of the view, we will flush the sections if we are | ||||
|             // done rendering all views so that there is nothing left hanging over when | ||||
|             // another view gets rendered in the future by the application developer. | ||||
|             $this->factory->flushSectionsIfDoneRendering(); | ||||
|  | ||||
|             return $response ?: $contents; | ||||
|             return ! is_null($response) ? $response : $contents; | ||||
|         } catch (Exception $e) { | ||||
|             $this->factory->flushSections(); | ||||
|  | ||||
|             throw $e; | ||||
|         } catch (Throwable $e) { | ||||
|             $this->factory->flushSections(); | ||||
|  | ||||
|             throw $e; | ||||
|         } | ||||
|     } | ||||
| @@ -125,10 +134,8 @@ class View implements ArrayAccess, ViewContract | ||||
|      */ | ||||
|     public function renderSections() | ||||
|     { | ||||
|         $env = $this->factory; | ||||
|  | ||||
|         return $this->render(function ($view) use ($env) { | ||||
|             return $env->getSections(); | ||||
|         return $this->render(function () { | ||||
|             return $this->factory->getSections(); | ||||
|         }); | ||||
|     } | ||||
|  | ||||
| @@ -186,7 +193,7 @@ class View implements ArrayAccess, ViewContract | ||||
|      * @param  array   $data | ||||
|      * @return $this | ||||
|      */ | ||||
|     public function nest($key, $view, array $data = array()) | ||||
|     public function nest($key, $view, array $data = []) | ||||
|     { | ||||
|         return $this->with($key, $this->factory->make($view, $data)); | ||||
|     } | ||||
| @@ -380,8 +387,8 @@ class View implements ArrayAccess, ViewContract | ||||
|      */ | ||||
|     public function __call($method, $parameters) | ||||
|     { | ||||
|         if (starts_with($method, 'with')) { | ||||
|             return $this->with(snake_case(substr($method, 4)), $parameters[0]); | ||||
|         if (Str::startsWith($method, 'with')) { | ||||
|             return $this->with(Str::snake(substr($method, 4)), $parameters[0]); | ||||
|         } | ||||
|  | ||||
|         throw new BadMethodCallException("Method [$method] does not exist on view."); | ||||
|   | ||||
| @@ -1,54 +1,55 @@ | ||||
| <?php namespace Illuminate\View; | ||||
| <?php | ||||
|  | ||||
| interface ViewFinderInterface { | ||||
| namespace Illuminate\View; | ||||
|  | ||||
| 	/** | ||||
| 	 * Hint path delimiter value. | ||||
| 	 * | ||||
| 	 * @var string | ||||
| 	 */ | ||||
| 	const HINT_PATH_DELIMITER = '::'; | ||||
| interface ViewFinderInterface | ||||
| { | ||||
|     /** | ||||
|      * Hint path delimiter value. | ||||
|      * | ||||
|      * @var string | ||||
|      */ | ||||
|     const HINT_PATH_DELIMITER = '::'; | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the fully qualified location of the view. | ||||
| 	 * | ||||
| 	 * @param  string  $view | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	public function find($view); | ||||
|     /** | ||||
|      * Get the fully qualified location of the view. | ||||
|      * | ||||
|      * @param  string  $view | ||||
|      * @return string | ||||
|      */ | ||||
|     public function find($view); | ||||
|  | ||||
| 	/** | ||||
| 	 * Add a location to the finder. | ||||
| 	 * | ||||
| 	 * @param  string  $location | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	public function addLocation($location); | ||||
|     /** | ||||
|      * Add a location to the finder. | ||||
|      * | ||||
|      * @param  string  $location | ||||
|      * @return void | ||||
|      */ | ||||
|     public function addLocation($location); | ||||
|  | ||||
| 	/** | ||||
| 	 * Add a namespace hint to the finder. | ||||
| 	 * | ||||
| 	 * @param  string  $namespace | ||||
| 	 * @param  string|array  $hints | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	public function addNamespace($namespace, $hints); | ||||
|     /** | ||||
|      * Add a namespace hint to the finder. | ||||
|      * | ||||
|      * @param  string  $namespace | ||||
|      * @param  string|array  $hints | ||||
|      * @return void | ||||
|      */ | ||||
|     public function addNamespace($namespace, $hints); | ||||
|  | ||||
| 	/** | ||||
| 	 * Prepend a namespace hint to the finder. | ||||
| 	 * | ||||
| 	 * @param  string  $namespace | ||||
| 	 * @param  string|array  $hints | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	public function prependNamespace($namespace, $hints); | ||||
|  | ||||
| 	/** | ||||
| 	 * Add a valid view extension to the finder. | ||||
| 	 * | ||||
| 	 * @param  string  $extension | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	public function addExtension($extension); | ||||
|     /** | ||||
|      * Prepend a namespace hint to the finder. | ||||
|      * | ||||
|      * @param  string  $namespace | ||||
|      * @param  string|array  $hints | ||||
|      * @return void | ||||
|      */ | ||||
|     public function prependNamespace($namespace, $hints); | ||||
|  | ||||
|     /** | ||||
|      * Add a valid view extension to the finder. | ||||
|      * | ||||
|      * @param  string  $extension | ||||
|      * @return void | ||||
|      */ | ||||
|     public function addExtension($extension); | ||||
| } | ||||
|   | ||||
| @@ -1,4 +1,6 @@ | ||||
| <?php namespace Illuminate\View; | ||||
| <?php | ||||
|  | ||||
| namespace Illuminate\View; | ||||
|  | ||||
| use Illuminate\View\Engines\PhpEngine; | ||||
| use Illuminate\Support\ServiceProvider; | ||||
| @@ -6,124 +8,119 @@ use Illuminate\View\Engines\CompilerEngine; | ||||
| use Illuminate\View\Engines\EngineResolver; | ||||
| use Illuminate\View\Compilers\BladeCompiler; | ||||
|  | ||||
| class ViewServiceProvider extends ServiceProvider { | ||||
| class ViewServiceProvider extends ServiceProvider | ||||
| { | ||||
|     /** | ||||
|      * Register the service provider. | ||||
|      * | ||||
|      * @return void | ||||
|      */ | ||||
|     public function register() | ||||
|     { | ||||
|         $this->registerEngineResolver(); | ||||
|  | ||||
| 	/** | ||||
| 	 * Register the service provider. | ||||
| 	 * | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	public function register() | ||||
| 	{ | ||||
| 		$this->registerEngineResolver(); | ||||
|         $this->registerViewFinder(); | ||||
|  | ||||
| 		$this->registerViewFinder(); | ||||
|         $this->registerFactory(); | ||||
|     } | ||||
|  | ||||
| 		$this->registerFactory(); | ||||
| 	} | ||||
|     /** | ||||
|      * Register the engine resolver instance. | ||||
|      * | ||||
|      * @return void | ||||
|      */ | ||||
|     public function registerEngineResolver() | ||||
|     { | ||||
|         $this->app->singleton('view.engine.resolver', function () { | ||||
|             $resolver = new EngineResolver; | ||||
|  | ||||
| 	/** | ||||
| 	 * Register the engine resolver instance. | ||||
| 	 * | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	public function registerEngineResolver() | ||||
| 	{ | ||||
| 		$this->app->singleton('view.engine.resolver', function() | ||||
| 		{ | ||||
| 			$resolver = new EngineResolver; | ||||
|             // Next we will register the various engines with the resolver so that the | ||||
|             // environment can resolve the engines it needs for various views based | ||||
|             // on the extension of view files. We call a method for each engines. | ||||
|             foreach (['php', 'blade'] as $engine) { | ||||
|                 $this->{'register'.ucfirst($engine).'Engine'}($resolver); | ||||
|             } | ||||
|  | ||||
| 			// Next we will register the various engines with the resolver so that the | ||||
| 			// environment can resolve the engines it needs for various views based | ||||
| 			// on the extension of view files. We call a method for each engines. | ||||
| 			foreach (array('php', 'blade') as $engine) | ||||
| 			{ | ||||
| 				$this->{'register'.ucfirst($engine).'Engine'}($resolver); | ||||
| 			} | ||||
|             return $resolver; | ||||
|         }); | ||||
|     } | ||||
|  | ||||
| 			return $resolver; | ||||
| 		}); | ||||
| 	} | ||||
|     /** | ||||
|      * Register the PHP engine implementation. | ||||
|      * | ||||
|      * @param  \Illuminate\View\Engines\EngineResolver  $resolver | ||||
|      * @return void | ||||
|      */ | ||||
|     public function registerPhpEngine($resolver) | ||||
|     { | ||||
|         $resolver->register('php', function () { | ||||
|             return new PhpEngine; | ||||
|         }); | ||||
|     } | ||||
|  | ||||
| 	/** | ||||
| 	 * Register the PHP engine implementation. | ||||
| 	 * | ||||
| 	 * @param  \Illuminate\View\Engines\EngineResolver  $resolver | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	public function registerPhpEngine($resolver) | ||||
| 	{ | ||||
| 		$resolver->register('php', function() { return new PhpEngine; }); | ||||
| 	} | ||||
|     /** | ||||
|      * Register the Blade engine implementation. | ||||
|      * | ||||
|      * @param  \Illuminate\View\Engines\EngineResolver  $resolver | ||||
|      * @return void | ||||
|      */ | ||||
|     public function registerBladeEngine($resolver) | ||||
|     { | ||||
|         $app = $this->app; | ||||
|  | ||||
| 	/** | ||||
| 	 * Register the Blade engine implementation. | ||||
| 	 * | ||||
| 	 * @param  \Illuminate\View\Engines\EngineResolver  $resolver | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	public function registerBladeEngine($resolver) | ||||
| 	{ | ||||
| 		$app = $this->app; | ||||
|         // The Compiler engine requires an instance of the CompilerInterface, which in | ||||
|         // this case will be the Blade compiler, so we'll first create the compiler | ||||
|         // instance to pass into the engine so it can compile the views properly. | ||||
|         $app->singleton('blade.compiler', function ($app) { | ||||
|             $cache = $app['config']['view.compiled']; | ||||
|  | ||||
| 		// The Compiler engine requires an instance of the CompilerInterface, which in | ||||
| 		// this case will be the Blade compiler, so we'll first create the compiler | ||||
| 		// instance to pass into the engine so it can compile the views properly. | ||||
| 		$app->singleton('blade.compiler', function($app) | ||||
| 		{ | ||||
| 			$cache = $app['config']['view.compiled']; | ||||
|             return new BladeCompiler($app['files'], $cache); | ||||
|         }); | ||||
|  | ||||
| 			return new BladeCompiler($app['files'], $cache); | ||||
| 		}); | ||||
|         $resolver->register('blade', function () use ($app) { | ||||
|             return new CompilerEngine($app['blade.compiler']); | ||||
|         }); | ||||
|     } | ||||
|  | ||||
| 		$resolver->register('blade', function() use ($app) | ||||
| 		{ | ||||
| 			return new CompilerEngine($app['blade.compiler'], $app['files']); | ||||
| 		}); | ||||
| 	} | ||||
|     /** | ||||
|      * Register the view finder implementation. | ||||
|      * | ||||
|      * @return void | ||||
|      */ | ||||
|     public function registerViewFinder() | ||||
|     { | ||||
|         $this->app->bind('view.finder', function ($app) { | ||||
|             $paths = $app['config']['view.paths']; | ||||
|  | ||||
| 	/** | ||||
| 	 * Register the view finder implementation. | ||||
| 	 * | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	public function registerViewFinder() | ||||
| 	{ | ||||
| 		$this->app->bind('view.finder', function($app) | ||||
| 		{ | ||||
| 			$paths = $app['config']['view.paths']; | ||||
|             return new FileViewFinder($app['files'], $paths); | ||||
|         }); | ||||
|     } | ||||
|  | ||||
| 			return new FileViewFinder($app['files'], $paths); | ||||
| 		}); | ||||
| 	} | ||||
|     /** | ||||
|      * Register the view environment. | ||||
|      * | ||||
|      * @return void | ||||
|      */ | ||||
|     public function registerFactory() | ||||
|     { | ||||
|         $this->app->singleton('view', function ($app) { | ||||
|             // Next we need to grab the engine resolver instance that will be used by the | ||||
|             // environment. The resolver will be used by an environment to get each of | ||||
|             // the various engine implementations such as plain PHP or Blade engine. | ||||
|             $resolver = $app['view.engine.resolver']; | ||||
|  | ||||
| 	/** | ||||
| 	 * Register the view environment. | ||||
| 	 * | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	public function registerFactory() | ||||
| 	{ | ||||
| 		$this->app->singleton('view', function($app) | ||||
| 		{ | ||||
| 			// Next we need to grab the engine resolver instance that will be used by the | ||||
| 			// environment. The resolver will be used by an environment to get each of | ||||
| 			// the various engine implementations such as plain PHP or Blade engine. | ||||
| 			$resolver = $app['view.engine.resolver']; | ||||
|             $finder = $app['view.finder']; | ||||
|  | ||||
| 			$finder = $app['view.finder']; | ||||
|             $env = new Factory($resolver, $finder, $app['events']); | ||||
|  | ||||
| 			$env = new Factory($resolver, $finder, $app['events']); | ||||
|             // We will also set the container instance on this view environment since the | ||||
|             // view composers may be classes registered in the container, which allows | ||||
|             // for great testable, flexible composers for the application developer. | ||||
|             $env->setContainer($app); | ||||
|  | ||||
| 			// We will also set the container instance on this view environment since the | ||||
| 			// view composers may be classes registered in the container, which allows | ||||
| 			// for great testable, flexible composers for the application developer. | ||||
| 			$env->setContainer($app); | ||||
|  | ||||
| 			$env->share('app', $app); | ||||
|  | ||||
| 			return $env; | ||||
| 		}); | ||||
| 	} | ||||
|             $env->share('app', $app); | ||||
|  | ||||
|             return $env; | ||||
|         }); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -14,11 +14,13 @@ | ||||
|         } | ||||
|     ], | ||||
|     "require": { | ||||
|         "php": ">=5.4.0", | ||||
|         "illuminate/container": "5.0.*", | ||||
|         "illuminate/contracts": "5.0.*", | ||||
|         "illuminate/filesystem": "5.0.*", | ||||
|         "illuminate/support": "5.0.*" | ||||
|         "php": ">=5.5.9", | ||||
|         "illuminate/container": "5.2.*", | ||||
|         "illuminate/contracts": "5.2.*", | ||||
|         "illuminate/events": "5.2.*", | ||||
|         "illuminate/filesystem": "5.2.*", | ||||
|         "illuminate/support": "5.2.*", | ||||
|         "symfony/debug": "2.8.*|3.0.*" | ||||
|     }, | ||||
|     "autoload": { | ||||
|         "psr-4": { | ||||
| @@ -27,7 +29,7 @@ | ||||
|     }, | ||||
|     "extra": { | ||||
|         "branch-alias": { | ||||
|             "dev-master": "5.0-dev" | ||||
|             "dev-master": "5.2-dev" | ||||
|         } | ||||
|     }, | ||||
|     "minimum-stability": "dev" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Sujit Prasad
					Sujit Prasad