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;
 }
 /**
  * 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 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}";
 }
Exemple #4
0
 /**
  * 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();
 }
Exemple #5
0
 /**
  * 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;
 }
Exemple #6
0
 /**
  * @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);
     }
 }
 /**
  * @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;
 }
Exemple #8
0
 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>');
 }
 /**
  * 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;
 }
 /**
  * @param string $name
  *
  * @return bool
  */
 private function staticViewExists(string $name) : bool
 {
     return $this->viewFactory->exists($this->staticViewName($name));
 }
 /**
  * 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}");
 }