/** * @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; }
/** * @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(); } }
/** * 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 menu($items) { if (!is_array($items)) { $items = $this->config->get($items, array()); } return $this->view->make('partials/menu', compact('items')); }
/** * @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; }
/** * 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)'); }
/** * {@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}"); } }
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); }
/** * @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; }
/** * 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); }
/** * @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); }
/** * @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')); }
/** * 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(); }); }
/** * 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(); }
/** * @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(); } }
/** * @param Sidebar $sidebar * * @return \Illuminate\Contracts\View\View */ public function render(Sidebar $sidebar) { $menu = $sidebar->getMenu(); if ($menu->isAuthorized()) { $groups = []; foreach ($menu->getGroups() as $group) { $groups[] = (new IlluminateGroupRenderer($this->factory))->render($group); } return $this->factory->make($this->view, ['groups' => $groups]); } }
/** * Renders a custom template or one of the default templates. * * The default template could be published (into resources/views/themes/) * or be located inside the components directory (vendor/styde/html/themes/) * * @param string $custom * @param array $data * @param null $template * @return string */ public function render($custom, $data = array(), $template = null) { if ($custom != null) { return $this->view->make($custom, $data)->render(); } $template = $this->theme . '/' . $template; if ($this->view->exists("themes/{$template}")) { return $this->view->make("themes/{$template}", $data)->render(); } return $this->view->make('styde.html::' . $template, $data)->render(); }
/** * @param Group $group * * @return \Illuminate\Contracts\View\View */ public function render(Group $group, $prefix = 'sidebar') { $this->view = $prefix . '::' . $this->view; if ($group->isAuthorized()) { $items = []; foreach ($group->getItems() as $item) { $items[] = (new IlluminateItemRenderer($this->factory))->render($item, $prefix); } return $this->factory->make($this->view, ['group' => $group, 'items' => $items])->render(); } }
/** * @param Request $request * @return \Psr\Http\Message\ResponseInterface */ public function render(Request $request) { $view = $this->view->make('flarum.install::app')->with('title', 'Install Flarum'); $this->prerequisite->check(); $errors = $this->prerequisite->getErrors(); if (count($errors)) { $view->with('content', $this->view->make('flarum.install::errors')->with('errors', $errors)); } else { $view->with('content', $this->view->make('flarum.install::install')); } return $view; }
/** * @param array $contentCollection * @param ContentInterface $source * @param ContentInterface $destination * * @return string */ public function describe(array $contentCollection, ContentInterface $source = null, ContentInterface $destination = null) { $content = reset($contentCollection); $count = count($contentCollection); $type = null; if ($count > 1) { $type = trans('content.type.' . $content->getType() . '.plural'); } else { $type = trans('content.type.' . $content->getType()); } return $this->viewFactory->make($this->getDescriptionView(), ['type' => $type, 'title' => $count > 1 ? null : $content->getTitle(), 'url' => $content->getUrl(), 'count' => $count > 1 ? $count : 'a', 'source_title' => $source ? $source->getTitle() : null, 'source_url' => $source ? $source->getUrl() : null, 'destination_title' => $destination ? $destination->getTitle() : null, 'destination_url' => $destination ? $destination->getUrl() : null]); }
/** * @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'); $this->prerequisite->check(); $errors = $this->prerequisite->getErrors(); 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; }
/** * {@inheritdoc} */ public function __invoke(Request $request, Response $response, callable $out = null) { try { $this->assertAdminAndSudo($request); } catch (Exception $e) { if ($request->getMethod() === 'POST') { $response = $this->logInController->handle($request); if ($response->getStatusCode() === 200) { return $response->withStatus(302)->withHeader('location', app('Flarum\\Admin\\UrlGenerator')->toRoute('index')); } } return new HtmlResponse($this->view->make('flarum.admin::login')->with('token', $request->getAttribute('session')->get('csrf_token'))->render()); } return $out ? $out($request, $response) : $response; }
function it_renders_default_templates(Factory $factory, View $view) { // Having $custom = null; $data = array(); $template = 'theme/template'; // Expect $factory->make(null, $data)->shouldNotBeCalled(); $factory->exists("themes/theme/{$template}")->shouldBeCalled()->willReturn(false); $factory->make("themes/theme/{$template}", [])->shouldNotBeCalled(); $factory->make("styde.html::theme/{$template}", [])->shouldBeCalled()->willReturn($view); $view->render()->shouldBeCalled()->willReturn('<html>'); // When $this->render($custom, $data, $template)->shouldReturn('<html>'); }
/** * Returns javascript that will bind the validation plugin to the specified form * * @param string $selector - CSS3 selector that selects the form to validate * @param array $options - Will be json_encode & passed to the $(form).validate(); call * @param array $data - Override view data * @return string */ public function create($selector = 'form', array $options = [], array $data = []) { $options['strategy'] = $this->getName(); $this->validatorOptions->put('laraval', $options); $data = array_replace_recursive(['selector' => $selector, 'rules' => $this->rules, 'embedAttributes' => $this->embedAttributes, 'embed' => $this->embed, 'options' => $this->validatorOptions], $data); return $this->viewFactory->make($this->view, $data)->render(); }
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']); }
/** * Render the likes into a string. * * @param Collection $likesCollection The likes to render. * * @param string $viewAllLikesLink The link to view all of the likes for the content. * * @return string */ public function render(Collection $likesCollection, $viewAllLikesLink) { $numLikesToList = $this->settings->get('posts.likes_to_show', 3); $numOtherLikes = $likesCollection->count() - $numLikesToList; $userId = $this->guard->user()->getAuthIdentifier(); $likes = []; $likesCollection = $likesCollection->filter(function (Like $like) use(&$likes, &$numLikesToList, $userId) { if ($like->user->id === $userId) { $like->user->name = $this->lang->get('likes.current_user'); $likes[] = $like; $numLikesToList--; return false; } return true; }); $numLikesInCollection = $likesCollection->count(); if ($numLikesInCollection > 0 && $numLikesToList > 0) { if ($numLikesInCollection < $numLikesToList) { $numLikesToList = $numLikesInCollection; } $randomLikes = $likesCollection->random($numLikesToList); if (!is_array($randomLikes)) { // random returns a single model if $numLikesToList is 1... $randomLikes = array($randomLikes); } foreach ($randomLikes as $key => $like) { $likes[] = $like; } } return $this->viewFactory->make('likes.list', compact('numOtherLikes', 'likes', 'viewAllLikesLink'))->render(); }
/** * Renders value of presentation. * * @param mixed $value Value of presentation. * @param array $parms Parameters to override. * @return string */ public function render($value, array $parms = []) { if (isset($value)) { return $this->view->make($this->getTemplate(), ['value' => $value, 'title' => $this->title, 'parms' => array_merge($this->parms, $parms)])->render(); } else { return '-'; } }
/** * @param $template * @return \Illuminate\Contracts\View\View */ protected function view($template) { if (Str::contains($template, '::')) { return $this->view->make($template); } else { return $this->view->make('themes::' . $template); } }