本文整理汇总了PHP中Illuminate\Contracts\View\Factory::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::exists方法的具体用法?PHP Factory::exists怎么用?PHP Factory::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Contracts\View\Factory
的用法示例。
在下文中一共展示了Factory::exists方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: render
/**
* 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);
}
示例3: handle
/**
* 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}";
}
示例4: render
/**
* 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();
}
示例5: compileCallback
/**
* Compile DataTable callback value.
*
* @param mixed $callback
* @return mixed|string
*/
private function compileCallback($callback)
{
if (is_callable($callback)) {
return value($callback);
} elseif ($this->view->exists($callback)) {
return $this->view->make($callback)->render();
}
return $callback;
}
示例6: renderHttpException
/**
* @param \Symfony\Component\HttpKernel\Exception\HttpException $exception
*
* @return \Symfony\Component\HttpFoundation\Response
*/
protected function renderHttpException(HttpException $exception)
{
$status = $exception->getStatusCode();
if ($this->view->exists("error::{$status}") && !$this->configuration->get('app.debug')) {
return $this->response->view("error::{$status}", ['exception' => $exception], $status, $exception->getHeaders());
} else {
return $this->convertExceptionToResponse($exception);
}
}
示例7: handle
/**
* @param LoadPageViewCommand $command
* @return View
*/
public function handle(LoadPageViewCommand $command)
{
$page = $command->getPage();
// Make sure we create the view once
if (!$page->getView()) {
try {
// Attempt to make default view
$page->setView($this->factory->make($page->getPath()));
} catch (\InvalidArgumentException $e) {
// If not, try it as a index within the folder
if ($this->factory->exists($page->getIndexPath())) {
$this->execute(new LoadPageViewIndexCommand($page));
} else {
$this->execute(new LoadPageView404Command($page));
}
}
$page->raise(new PageViewLoaded($page));
}
return $page;
}
示例8: array
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>');
}
示例9: getOverloadPath
/**
* Get the override view path.
*
* @param $view
* @return null|string
*/
public function getOverloadPath(View $view)
{
/**
* We can only overload namespaced
* views right now.
*/
if (!str_contains($view->getName(), '::')) {
return null;
}
/**
* Split the view into it's
* namespace and path.
*/
list($namespace, $path) = explode('::', $view->getName());
$path = str_replace('.', '/', $path);
/**
* If the module is shorthand
* then check to see if we have
* an active module to use for it.
*/
if ($namespace === 'module' && $this->module) {
$namespace = $this->module->getNamespace();
}
/**
* If the view is already in
* the theme then skip it.
*/
if ($namespace == 'theme' || str_is('*.theme.*', $namespace)) {
return null;
}
/**
* If the view is a streams view then
* it's real easy to guess what the
* override path should be.
*/
if ($namespace == 'streams') {
$path = $this->theme->getNamespace('streams/' . $path);
}
/**
* If the view uses a dot syntax namespace then
* transform it all into the override view path.
*/
if ($addon = $this->addons->get($namespace)) {
$path = $this->theme->getNamespace("addons/{$addon->getVendor()}/{$addon->getSlug()}-{$addon->getType()}/" . $path);
}
if ($this->view->exists($path)) {
return $path;
}
/**
* If the view uses a dot syntax namespace then
* transform it all into the override view path.
*
* @deprecated since v3.0.0
*/
if ($addon) {
$path = $this->theme->getNamespace("addon/{$addon->getVendor()}/{$addon->getSlug()}-{$addon->getType()}/" . $path);
}
if ($this->view->exists($path)) {
return $path;
}
return null;
}
示例10: staticViewExists
/**
* @param string $name
*
* @return bool
*/
private function staticViewExists(string $name) : bool
{
return $this->viewFactory->exists($this->staticViewName($name));
}
示例11: canDisplay
/**
* Can we display the exception?
*
* @param \Exception $original
* @param \Exception $transformed
* @param int $code
*
* @return bool
*/
public function canDisplay(Exception $original, Exception $transformed, $code)
{
return $this->factory->exists("errors.{$code}");
}