/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $this->request = $request; $this->view->share('now', Carbon::now()); $this->response = $next($this->request); $this->buildCsp(); return $this->response; }
/** * 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()); // 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); }
/** * 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')); } else { $this->view->share('errors', new ViewErrorBag()); } return $next($request); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if ($request->session()->has('infos')) { $this->view->share('infos', $request->session()->get('infos')); } else { $this->view->share('infos', new MessageBag()); } if ($request->session()->has('warnings')) { $this->view->share('warnings', $request->session()->get('warnings')); } else { $this->view->share('warnings', new MessageBag()); } return $next($request); }
function it_shares_the_notifications_from_the_session(Notifier $notifier, Factory $viewFactory, Request $request) { $notifications = Notifications::mapFromArray([]); $notifier->getCurrentNotifications()->willReturn($notifications); $viewFactory->share('notifications', $notifications)->shouldBeCalled(); $next = function ($req) use($request) { return $req === $request->getWrappedObject(); }; $this->handle($request, $next)->shouldBe(true); }
/** * @param $key * @param null $value */ protected function share($key, $value = null) { $this->view->share($key, $value); }
/** * @param $key * @param $value */ public function share($key, $value) { $this->view->share($key, $value); }
/** * Handle an incoming request. * * @param Request $request * @param Closure $next * @return mixed */ public function handle($request, Closure $next) { $notifications = $this->notifier->getCurrentNotifications(); $this->viewFactory->share('notifications', $notifications); return $next($request); }
/** * @param \Codex\Codex $codex * @param \Illuminate\Contracts\View\Factory|\Illuminate\View\Factory $view */ public function __construct(Codex $codex, ViewFactory $view) { $this->codex = $codex; $this->view = $view; $view->share('codex', $codex); }
protected function setGlobalViewVariables() { $this->view->share('guard', $this->guard); $this->view->share('version', Entity::VERSION); }
/** * Middleware handler. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed */ public function handle(Request $request, \Closure $next) { $this->view->share('errors', $request->session()->get('messages') ?: new ViewErrorBag()); return $next($request); }