本文整理汇总了PHP中Illuminate\Routing\ResponseFactory类的典型用法代码示例。如果您正苦于以下问题:PHP ResponseFactory类的具体用法?PHP ResponseFactory怎么用?PHP ResponseFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ResponseFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Handle the command.
*
* @param ResponseFactory $response
*/
public function handle(ResponseFactory $response)
{
$tree = $this->builder->getTree();
$options = $tree->getOptions();
$data = $tree->getData();
$tree->setResponse($response->view($options->get('wrapper_view', 'streams::blank'), $data));
}
示例2: handle
/**
* Handle the command.
*
* @param ResponseFactory $response
*/
public function handle(ResponseFactory $response)
{
$table = $this->builder->getTable();
$options = $table->getOptions();
$data = $table->getData();
$table->setResponse($response->view($options->get('wrapper_view', $this->builder->isAjax() ? 'streams::ajax' : 'streams::blank'), $data));
}
示例3: handle
/**
* Handle the command.
*
* @param ResponseFactory $response
* @param Request $request
*/
public function handle(ResponseFactory $response, Request $request)
{
/* @var TableBuilder $builder */
foreach ($this->builder->getTables() as $builder) {
$builder->post();
}
if (!$this->builder->getTableResponse()) {
$this->builder->setTableResponse($response->redirectTo($request->fullUrl()));
}
}
示例4: handle
/**
* Handle the command.
*
* @param Request $request
* @param ResponseFactory $response
* @throws \Exception
*/
public function handle(Request $request, ResponseFactory $response)
{
if ($this->builder instanceof MultipleTableBuilder) {
return;
}
$this->dispatch(new ExecuteAction($this->builder));
if (!$this->builder->getTableResponse()) {
$this->builder->setTableResponse($response->redirectTo($request->fullUrl()));
}
}
示例5: handle
/**
* ExportAll the selected entries.
*
* @param TableBuilder $builder
* @param ResponseFactory $response
* @param array $selected
*/
public function handle(TableBuilder $builder, ResponseFactory $response, array $selected)
{
$model = $builder->getTableModel();
$stream = $builder->getTableStream();
$headers = ['Content-Disposition' => 'attachment; filename=' . $stream->getSlug() . '.csv', 'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0', 'Content-type' => 'text/csv', 'Pragma' => 'public', 'Expires' => '0'];
$callback = function () use($selected, $model) {
$output = fopen('php://output', 'w');
/* @var EloquentModel $entry */
foreach ($model->all() as $k => $entry) {
if ($k == 0) {
fputcsv($output, array_keys($entry->toArray()));
}
fputcsv($output, $entry->toArray());
}
fclose($output);
};
$builder->setTableResponse($response->stream($callback, 200, $headers));
}
示例6: ajax
/**
* @param HostnameRepositoryContract $hostname
* @param ResponseFactory $response
* @return \Illuminate\Http\JsonResponse
*/
public function ajax(HostnameRepositoryContract $hostname, ResponseFactory $response)
{
return $response->json($hostname->ajaxQuery('hostname'));
}
示例7: handle
/**
* Handle the command.
*
* @param ResponseFactory $response
*/
public function handle(ResponseFactory $response)
{
$this->builder->setFormResponse($response->json(['errors' => $this->builder->getFormErrors()->getMessages(), 'redirect' => $this->builder->getFormOption('redirect', $this->builder->getFormActions()->active()->getRedirect())]));
}
示例8: handle
/**
* Handle the command.
*
* @param ResponseFactory $response
*/
public function handle(ResponseFactory $response)
{
$options = $this->builder->getFormOptions();
$data = $this->builder->getFormData();
$this->builder->setFormResponse($response->view($options->get('wrapper_view'), $data));
}
示例9: handle
public function handle(ResponseFactory $factory)
{
$response = ['data' => $this->content, 'status' => $this->status];
return $factory->json($response, $this->status, $this->headers, $this->options);
}
示例10: handle
public function handle(ResponseFactory $factory)
{
return $factory->view($this->template, $this->data, $this->status, $this->headers);
}
示例11: authorize
/**
* Authorize the page.
*
* @param PageInterface $page
*/
public function authorize(PageInterface $page)
{
/* @var UserInterface $user */
$user = $this->guard->user();
/**
* If the page is not enabled and we
* are not logged in then 404.
*/
if (!$page->isEnabled() && !$user) {
abort(404);
}
/**
* If the page is not enabled and we are
* logged in then make sure we have permission.
*/
if (!$page->isEnabled()) {
$this->authorizer->authorize('anomaly.module.pages::view_drafts');
}
/**
* If the page is restricted to specific
* roles then make sure our user is one of them.
*/
$allowed = $page->getAllowedRoles();
if (!$allowed->isEmpty() && (!$user || !$user->hasAnyRole($allowed))) {
$page->setResponse($this->response->redirectTo('login'));
}
}
示例12: make
/**
* Make the response.
*
* @param FileInterface $file
* @return Response
*/
public function make(FileInterface $file)
{
// Start the response.
$response = $this->response->make();
$response->headers->set('Etag', $file->etag());
$response->headers->set('Content-Type', $file->getMimetype());
$response->headers->set('Last-Modified', $file->lastModified()->setTimezone('GMT')->format('D, d M Y H:i:s'));
$response->setTtl(3600);
return $response;
}
示例13: make
/**
* Make the response.
*
* @param FileInterface $file
* @return Response
*/
public function make(FileInterface $file)
{
// Start the response.
$response = $this->response->make();
$response->headers->set('Pragma', 'public');
$response->headers->set('Etag', $file->hash());
$response->headers->set('Content-Length', $file->getSize());
$response->headers->set('Content-Type', $file->getMimetype());
$response->headers->set('Cache-Control', 'public,max-age=300,s-maxage=900');
// Should be configurable
$response->headers->set('Last-Modified', $file->lastModified()->setTimezone('GMT')->format('D, d M Y H:i:s'));
return $response;
}
示例14: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
if ($this->guard->guest()) {
if ($request->ajax()) {
return $this->response->make('Unauthorized.', 401);
} else {
if ($request->segment(1) === 'admin') {
return $this->redirect->guest('admin/login');
} else {
return $this->redirect->guest('login');
}
}
}
return $next($request);
}
示例15: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
$response = $this->security->check($this->guard->user());
if ($response instanceof Response) {
return $response;
}
if ($this->guard->guest()) {
if ($request->ajax()) {
return $this->response->make('Unauthorized.', 401);
} else {
if ($request->segment(1) === 'admin') {
return $this->redirect->guest('admin/login');
} else {
return $this->redirect->guest('login');
}
}
}
return $next($request);
}