本文整理汇总了PHP中Illuminate\Contracts\View\Factory类的典型用法代码示例。如果您正苦于以下问题:PHP Factory类的具体用法?PHP Factory怎么用?PHP Factory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Factory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* 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());
}
示例2: place
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']);
}
示例3: boot
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);
}
示例4: boot
/**
* 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);
}
示例5: execute
/**
* {@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',
]));
*/
}
示例6: viewAction
/**
* @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'));
}
示例7: handle
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;
}
示例8: generate
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);
}
示例9: render
/**
* @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;
}
示例10: handle
/**
* 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);
}
示例11: registerViewExtension
protected function registerViewExtension()
{
$hasExtension = in_array('stub', $this->view->getExtensions(), true);
if ($hasExtension === false) {
$this->view->addExtension('stub', 'blade');
}
}
示例12: render
/**
* @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();
}
}
示例13: renderer
/**
* 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)');
}
示例14: handle
/**
* @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;
}
示例15: menu
public function menu($items)
{
if (!is_array($items)) {
$items = $this->config->get($items, array());
}
return $this->view->make('partials/menu', compact('items'));
}