/** * 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)); }
/** * 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')); } }
/** * 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)); }
/** * 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; }
/** * 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())); } }
/** * 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())); } }
/** * 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; }
/** * 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); }
/** * 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)); }
/** * 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); }
/** * 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')) { abort(403); } /** * If the page is restricted to specific * roles then make sure our user is one of them. */ $allowed = $page->getAllowedRoles(); /** * If there is a guest role and * there IS a user then this * page can NOT display. */ if ($allowed->has('guest') && $user && !$user->isAdmin()) { abort(403); } // No longer needed. $allowed->forget('guest'); /** * Check the roles against the * user if there are any. */ if (!$allowed->isEmpty() && (!$user || !$user->hasAnyRole($allowed) && !$user->isAdmin())) { $page->setResponse($this->response->redirectGuest('login')); } }
/** * @param HostnameRepositoryContract $hostname * @param ResponseFactory $response * @return \Illuminate\Http\JsonResponse */ public function ajax(HostnameRepositoryContract $hostname, ResponseFactory $response) { return $response->json($hostname->ajaxQuery('hostname')); }
/** * Search for the vacancies * * @return \Illuminate\Http\JsonResponse */ public function search() { $data = $this->vacancy->search($this->request->input('q'), $this->getOptionInputs()); return $this->response->json(['vacancies' => $data]); }
/** * Fire event and return the response * * @param string $event * @param string $error * @param integer $status * @param array $payload * @return mixed */ protected function respond($event, $error, $status, $payload = []) { $response = $this->events->fire($event, $payload, true); return $response ?: $this->response->json(['error' => $error], $status); }
/** * 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())])); }
/** * 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)); }
/** * Show a single press release * * In order to be compatible with the old press releases module the year, month, and day are passed. * But here is the secret... They don't matter. Only the slug matters * * @param PressReleaseRepositoryInterface $repo * @param $year * @param $month * @param $day * @param $slug * @return \Symfony\Component\HttpFoundation\Response */ public function show(PressReleaseRepositoryInterface $repo, $year, $month, $day, $slug) { $press_release = $repo->getBySlug($slug); return $this->response->view('control_4.module.press_releases::show', compact('press_release')); }
public function handle(ResponseFactory $factory) { $response = ['data' => $this->content, 'status' => $this->status]; return $factory->json($response, $this->status, $this->headers, $this->options); }
public function handle(ResponseFactory $factory) { return $factory->view($this->template, $this->data, $this->status, $this->headers); }
/** * Fire event and return the response * * @param string $event * @param string $error * @param integer $status * @param array $payload * @return mixed */ protected function respond($event, $error, $status, $payload = []) { $response = $this->events->fire($event, $payload, true); return $response ?: $this->response->json(arrayView('phpsoft.users::errors/authenticate', ['error' => $error]), $status); }
public function handle(ResponseFactory $response) { return $response->json($this->content, $this->status, $this->headers, $this->options); }
/** * Search for books * * @return \Illuminate\Http\JsonResponse */ public function search() { $books = $this->book->search($this->request->input('q'), $this->getAdvancedQueryInputs(), $this->getOptionInputs()); return $books !== false ? $this->response->json(['found' => $books]) : $this->response->json(['error' => $this->book->getErrors()], 400); }
/** * Checks if macro is registered. * * @param string $name * @return bool * @static */ public static function hasMacro($name) { return \Illuminate\Routing\ResponseFactory::hasMacro($name); }
public function handle(Larasponse $larasponse, ResponseFactory $response) { $item = $larasponse->item($this->data, $this->transformer); return $response->json($item, $this->status, $this->headers, $this->options); }