[李景山php]每天laravel-20161108|ShareErrorsFromSession.php
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[李景山php]每天laravel-20161108|ShareErrorsFromSession.php相关的知识,希望对你有一定的参考价值。
<?php namespace Illuminate\View\Middleware; use Closure; use Illuminate\Support\ViewErrorBag; use Illuminate\Contracts\View\Factory as ViewFactory; class ShareErrorsFromSession { /** * The view factory implementation. * * @var \Illuminate\Contracts\View\Factory */ protected $view;// The view factory implementation /** * Create a new error binder instance. * * @param \Illuminate\Contracts\View\Factory $view * @return void */ public function __construct(ViewFactory $view) { $this->view = $view;//set this view }//Create a new error binder instance. /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) {//Handle an incoming request. // 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 );//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. // 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); //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. } }
本文出自 “专注php 群号:414194301” 博客,请务必保留此出处http://jingshanls.blog.51cto.com/3357095/1846655
以上是关于[李景山php]每天laravel-20161108|ShareErrorsFromSession.php的主要内容,如果未能解决你的问题,请参考以下文章
[李景山php]每天laravel-20161028|Translator.php
[李景山php]每天laravel-20161107|PhpEngine.php
[李景山php]每天laravel-20161106|EngineResolver.php
[李景山php]每天laravel-20161108|ShareErrorsFromSession.php