本文整理汇总了PHP中Illuminate\Contracts\View\Factory::share方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::share方法的具体用法?PHP Factory::share怎么用?PHP Factory::share使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Contracts\View\Factory
的用法示例。
在下文中一共展示了Factory::share方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* 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;
}
示例2: handle
/**
* 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);
}
示例3: handle
/**
* 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);
}
示例4: handle
/**
* 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);
}
示例5: function
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);
}
示例6: share
/**
* @param $key
* @param null $value
*/
protected function share($key, $value = null)
{
$this->view->share($key, $value);
}
示例7: share
/**
* @param $key
* @param $value
*/
public function share($key, $value)
{
$this->view->share($key, $value);
}
示例8: handle
/**
* 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);
}
示例9: __construct
/**
* @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);
}
示例10: setGlobalViewVariables
protected function setGlobalViewVariables()
{
$this->view->share('guard', $this->guard);
$this->view->share('version', Entity::VERSION);
}
示例11: handle
/**
* 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);
}