/** * @param Request $request * @param array $routeParams * @return \Psr\Http\Message\ResponseInterface|EmptyResponse */ public function render(Request $request, array $routeParams = []) { $view = $this->view->make('flarum.install::app'); $view->logo = $this->view->make('flarum.install::logo'); $errors = []; if (version_compare(PHP_VERSION, '5.5.0', '<')) { $errors[] = ['message' => '<strong>PHP 5.5+</strong> is required.', 'detail' => 'You are running version ' . PHP_VERSION . '. Talk to your hosting provider about upgrading to the latest PHP version.']; } foreach (['mbstring', 'pdo_mysql', 'openssl', 'json', 'gd', 'dom'] as $extension) { if (!extension_loaded($extension)) { $errors[] = ['message' => 'The <strong>' . $extension . '</strong> extension is required.']; } } $paths = [public_path(), public_path() . '/assets', storage_path()]; foreach ($paths as $path) { if (!is_writable($path)) { $errors[] = ['message' => 'The <strong>' . realpath($path) . '</strong> directory is not writable.', 'detail' => 'Please chmod this directory ' . ($path !== public_path() ? ' and its contents' : '') . ' to 0775.']; } } if (count($errors)) { $view->content = $this->view->make('flarum.install::errors'); $view->content->errors = $errors; } else { $view->content = $this->view->make('flarum.install::install'); } return $view; }
/** * construct. * * @param \Illuminate\Contracts\Mail\Mailer $mailer * @param \Illuminate\Filesystem\Filesystem $filesystem * @param \Illuminate\Contracts\View\Factory $viewFactory */ public function __construct(MailerContract $mailer, Filesystem $filesystem, ViewFactory $viewFactory) { $this->mailer = $mailer; $this->filesystem = $filesystem; $this->viewFactory = $viewFactory; $this->viewFactory->addNamespace($this->viewNamespace, $this->storagePath()); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed */ public function handle($request, Closure $next) { if ($this->app->isDownForMaintenance()) { return new Response($this->view->make('maintenance')->render(), 503); } return $next($request); }
public function place(Order $orderModel, OrderItem $orderItem, CheckoutService $checkoutService, Factory $factory) { if (!Session::has('cart')) { return false; } $cart = Session::get('cart'); if ($cart->getTotal() > 0) { $order = $orderModel->create(['user_id' => Auth::user()->id, 'total' => $cart->getTotal()]); // Criação da classe de checkout para integração com o pagseguro //$checkout = $checkoutService->createCheckoutBuilder(); foreach ($cart->all() as $k => $item) { $order->items()->create(['product_id' => $k, 'price' => $item['price'], 'qtd' => $item['qtd']]); //$checkout->addItem(new Item($k, $item['name'], number_format($item['price'], 2, '.', ''), $item['qtd'])); } $cart->clear(); event(new CheckoutEvent(Auth::user(), $order)); // Na verdade esse lugar não é exatamente o melhor lugar para se colocar o redirecionamento para // o pagseguro, porém por hora irá servir; //$response = $checkoutService->checkout($checkout->getCheckout()); //return view('store.checkout', compact('order')); return view('store.checkout', ['order' => $order, 'cart' => 'vazio']); //return redirect($response->getRedirectionUrl()); } return $factory->make('store.checkout', ['cart' => 'empty']); //return view('store.checkout', ['cart' => 'empty']); }
public function boot(Factory $view) { $this->loadViewsFrom(__DIR__ . '/Views', 'toolbox'); $this->publishes([__DIR__ . '/Views' => base_path('resources/views/vendor/toolbox')]); // We need to register our view composer for errorPartial to properly set all variables $view->composer('vendor.toolbox.errors.errorPartial', ErrorPartialComposer::class); }
/** * Bootstrap the application services. */ public function boot(Router $router, ViewFactory $view) { $view->addNamespace('admin', resource_path('views/admin')); // route model binding for admin routes $router->model('content_page', Page::class); $this->bootAdminRoutes($router); }
protected function registerViewExtension() { $hasExtension = in_array('stub', $this->view->getExtensions(), true); if ($hasExtension === false) { $this->view->addExtension('stub', 'blade'); } }
/** * @param Append $append * * @return \Illuminate\Contracts\View\View */ public function render(Append $append, $prefix = 'sidebar') { $this->view = $prefix . '::' . $this->view; if ($append->isAuthorized()) { return $this->factory->make($this->view, ['append' => $append])->render(); } }
/** * Render the breadcrumbs view. * * @param $view * @param $breadcrumbs * @return string * @throws Exception */ public function renderer($view, $breadcrumbs) { if (!is_null($view)) { return $this->master->make($view, compact('breadcrumbs'))->render(); } throw new Exception('Breadcrumbs view not specified (check the view in config/breadcrumbs.php, and ensure DaveJamesMiller\\Breadcrumbs\\ServiceProvider is loaded before any dependants in config/app.php)'); }
/** * @param LoadPageViewIndexCommand $command * @return \Anomaly\FizlPages\Page\Contract\Page */ public function handle(LoadPageViewIndexCommand $command) { $page = $command->getPage(); $page->setView($this->factory->make($page->getIndexPath())); $page->raise(new PageViewIndexLoaded($page)); return $page; }
public function menu($items) { if (!is_array($items)) { $items = $this->config->get($items, array()); } return $this->view->make('partials/menu', compact('items')); }
/** * {@inheritdoc} */ public function execute($request) { /** @var $request ObtainCreditCard */ if (false == $this->supports($request)) { throw RequestNotSupportedException::createActionNotSupported($this, $request); } if ($this->request->isMethod('POST')) { $creditCard = new CreditCard(); $creditCard->setHolder($this->request->get('card_holder')); $creditCard->setNumber($this->request->get('card_number')); $creditCard->setSecurityCode($this->request->get('card_cvv')); $creditCard->setExpireAt(new DateTime($this->request->get('card_expire_at'))); $request->set($creditCard); return; } $form = $this->viewFactory->make($this->templateName, ['model' => $request->getModel(), 'firstModel' => $request->getFirstModel(), 'actionUrl' => $request->getToken() ? $request->getToken()->getTargetUrl() : null]); throw new HttpResponse(new Response($form->render(), 200, ['Cache-Control' => 'no-store, no-cache, max-age=0, post-check=0, pre-check=0', 'X-Status-Code' => 200, 'Pragma' => 'no-cache'])); /* $content = $this->viewFactory->make($this->templateName, [ 'model' => $request->getModel(), 'firstModel' => $request->getFirstModel(), 'form' => $form->render(), 'actionUrl' => $request->getToken() ? $request->getToken()->getTargetUrl() : null, ]); $this->gateway->execute($renderTemplate); throw new HttpResponse(new Response($renderTemplate->getResult(), 200, [ 'Cache-Control' => 'no-store, no-cache, max-age=0, post-check=0, pre-check=0', 'X-Status-Code' => 200, 'Pragma' => 'no-cache', ])); */ }
/** * Execute the console command. * * @return void */ public function fire() { $this->registerClassAutoloadExceptions(); $bindings = array(); foreach ($this->getAbstracts() as $abstract) { // Validator and seeder cause problems if (in_array($abstract, ['validator', 'seeder'])) { continue; } try { $concrete = $this->laravel->make($abstract); if (is_object($concrete)) { $class = get_class($concrete); if (strpos($class, 'Proxy_') === 0) { $class = get_parent_class($class); } $bindings[$abstract] = $class; } } catch (\Exception $e) { if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { $this->comment("Cannot make '{$abstract}': " . $e->getMessage()); } } } $content = $this->view->make('ide-helper::meta', ['bindings' => $bindings, 'methods' => $this->methods])->render(); $filename = $this->option('filename'); $written = $this->files->put($filename, $content); if ($written !== false) { $this->info("A new meta file was written to {$filename}"); } else { $this->error("The meta file could not be created at {$filename}"); } }
/** * @param int $tagId * @param string $tagName * * @throws \Illuminate\Database\Eloquent\ModelNotFoundException * * @return \Illuminate\Contracts\View\View|\Illuminate\Http\RedirectResponse */ public function viewAction(int $tagId, string $tagName) { $tag = $this->tagRepository->loadById($tagId); if ($tag->name !== $tagName) { return $this->responseFactory->redirectToRoute('tag.view', ['id' => $tag->id, $tag->name]); } return $this->viewFactory->make('customer.tag.view', compact('tag')); }
/** * @param LoadPageView404Command $command * @return Page */ public function handle(LoadPageView404Command $command) { $page = $command->getPage(); $page->setView($this->factory->make($page->getMissingPath())); $page->setMissing(true); $page->raise(new PageView404Loaded($page)); return $page; }
public function handle(CheckPageExistsCommand $command) { $page = $this->pageFactory->create($command->getUri(), $command->getNamespace()); if (!($exist = $this->view->exists($page->getPath()))) { $exist = $this->view->exists($page->getIndexPath()); } return $exist; }
public function generate() { $files = $this->documentation->getAllFiles(); $view = $this->viewFactory->make('documentation::route_templates.routes', compact('files')); $filePath = storage_path() . "/routes/documentation_routes.php"; $fileContents = "<?php\n\n" . $view->render(); $this->finder->put($filePath, $fileContents); }
/** * 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; }
/** * @param Request $request * @return \Illuminate\Contracts\View\View * @throws InvalidConfirmationTokenException */ public function render(Request $request) { $token = array_get($request->getQueryParams(), 'token'); $token = PasswordToken::findOrFail($token); if ($token->created_at < new DateTime('-1 day')) { throw new InvalidConfirmationTokenException(); } return $this->view->make('flarum::reset')->with('translator', $this->translator)->with('passwordToken', $token->id)->with('csrfToken', $request->getAttribute('session')->get('csrf_token')); }
/** * Render an exception into an HTTP response. * * @param \Illuminate\Http\Request $request * @param \Exception $e * * @return \Illuminate\Http\Response */ public function render($request, Exception $e) { if ($e instanceof HttpException) { if ($this->view->exists('errors.' . $e->getStatusCode())) { return $this->view->make('errors.' . $e->getStatusCode(), ['request' => $request, 'exception' => $e]); } } return parent::render($request, $e); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @param string $routeString * @return mixed */ public function handle($request, Closure $next, $routeString) { if (!$request->ajax()) { if ($this->view->getFinder()->getDevice() === 'default') { return redirect()->route($routeString); } } return $next($request); }
/** * boot. * * @method boot * * @param \Illuminate\Contracts\View\Factory $viewFactory * @param \Illuminate\Routing\Router $router */ public function boot(ViewFactory $viewFactory, Router $router) { $viewFactory->addNamespace('payum', __DIR__ . '/../resources/views'); $config = $this->app['config']['payum']; $this->handleRoutes($router, $config); if ($this->app->runningInConsole() === true) { $this->handlePublishes(); } }
/** * @param Request $request * @param array $routeParams * @return \Illuminate\Contracts\View\View */ public function render(Request $request, array $routeParams = []) { $token = array_get($routeParams, 'token'); $token = PasswordToken::findOrFail($token); if ($token->created_at < new DateTime('-1 day')) { throw new InvalidConfirmationTokenException(); } return $this->view->make('flarum::reset')->with('token', $token->id); }
/** * Render a string template. * * @param $template * @param array $payload * @return string * @throws \Exception */ function render($template, array $payload = []) { $view = 'templates/' . md5($template); $path = $this->application->getStoragePath($view); if (!$this->files->isDirectory($directory = dirname($path))) { $this->files->makeDirectory($directory, 0777, true); } $this->files->put($path . '.twig', $template); return $this->view->make('storage::' . $view, $payload)->render(); }
/** * Setup the blade compiler class. * * @param \Illuminate\Contracts\View\Factory $view * * @return void */ protected function setupBlade(View $view) { $blade = $view->getEngineResolver()->resolve('blade')->getCompiler(); $blade->directive('auth', function ($expression) { return "<?php if (\\GrahamCampbell\\Credentials\\Facades\\Credentials::check() && \\GrahamCampbell\\Credentials\\Facades\\Credentials::hasAccess{$expression}): ?>"; }); $blade->directive('endauth', function () { return '<?php endif; ?>'; }); }
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); }
/** * Handle the command. * * @param Factory $view * @return string */ public function handle(Factory $view) { if ($view->exists($this->layout)) { return $this->layout; } if ($view->exists($layout = "theme::layouts/{$this->layout}")) { return $layout; } return "theme::layouts/{$this->default}"; }
/** * @param Group $group * * @return \Illuminate\Contracts\View\View */ public function render(Group $group) { if ($group->isAuthorized()) { $items = []; foreach ($group->getItems() as $item) { $items[] = (new IlluminateItemRenderer($this->factory))->render($item); } return $this->factory->make($this->view, ['group' => $group, 'items' => $items])->render(); } }
/** * Returns the cached view * * @param string $view * @param mixed|null $data * @param mixed|null $prefix * @param mixed|null $tags * * @return string */ public function get($view, $data = null, $prefix = null, $tags = null) { $key = $this->makeKey($view, (array) $data, (array) $prefix); if (!$this->shouldCache) { return $this->view->make($view, $data)->render(); } return $this->getCache((array) $tags)->rememberForever($key, function () use($view, $data) { return $this->view->make($view, (array) $data)->render(); }); }
/** * 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); }