setResourcesPath() public method

Deprecation:
public setResourcesPath ( string $resourcesPath ) : void
$resourcesPath string
return void
Exemplo n.º 1
0
 /**
  * Constructor.
  *
  * @param array $configs
  *
  * @since 0.0.6
  */
 public function __construct($configs = [])
 {
     // Use Whoops vendor to display errors
     $run = new Run();
     // New Pretty handler
     $handler = new PrettyPageHandler();
     // Custom tables
     if (!empty($configs)) {
         $handler->addDataTable('Olympus configurations', $configs);
     }
     // Page title
     $handler->setPageTitle('Whoops! There was a problem.');
     // Page custom CSS
     $handler->setResourcesPath(WEBPATH . 'resources' . S . 'whoops' . S);
     $handler->addCustomCss('olympoops.base.css');
     // Push all in handler
     $run->pushHandler($handler);
     // AJAX requests
     if (Misc::isAjaxRequest()) {
         $run->pushHandler(new JsonResponseHandler());
     }
     // Handler registration
     $run->register();
 }
 /**
  * Register the "pretty" Whoops handler.
  *
  * @return void
  */
 protected function registerPrettyWhoopsHandler()
 {
     $me = $this;
     $this->app['whoops.handler'] = function () use($me) {
         with($handler = new PrettyPageHandler())->setEditor('sublime');
         // If the resource path exists, we will register the resource path with Whoops
         // so our custom Laravel branded exception pages will be used when they are
         // displayed back to the developer. Otherwise, the default pages are run.
         if (!is_null($path = $me->resourcePath())) {
             $handler->setResourcesPath($path);
         }
         return $handler;
     };
 }
Exemplo n.º 3
0
 /**
  * Configure handler
  * Right now there are 2 handlers: onNotFound and onError
  *
  * @return void
  */
 protected function configureHandler()
 {
     if ($this->config('_handlerConfigured') !== true) {
         $app = $this;
         if ($this->config('bono.cli') !== true) {
             $this->whoops = new Run();
             $handler = new PrettyPageHandler();
             $path = explode(DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR, __DIR__);
             $path = $path[0] . '/templates/_whoops';
             $handler->setResourcesPath($path);
             $jsonResponseHandler = new JsonResponseHandler();
             $jsonResponseHandler->onlyForAjaxRequests(true);
             $appHandler = function ($err) use($app, $handler) {
                 if (!isset($app->request)) {
                     return;
                 }
                 $template = 'error.php';
                 if ($err->getMessage() === '404 Resource not found') {
                     $template = 'notFound.php';
                 }
                 $request = $app->request;
                 // Add some custom tables with relevant info about your application,
                 // that could prove useful in the error page:
                 $handler->addDataTable('Bono Application', array('Template' => 'Modify this page on templates/' . $template, 'Application Class' => get_class($app), 'Charset' => $request->headers('ACCEPT_CHARSET') ?: '<none>', 'Locale' => $request->getContentCharset() ?: '<none>'));
                 $handler->addDataTable('Bono Request', array('URI' => $request->getRootUri(), 'Request URI' => $request->getResourceUri(), 'Path' => $request->getPath(), 'Query String' => $request->params() ?: '<none>', 'HTTP Method' => $request->getMethod(), 'Script Name' => $request->getScriptName(), 'Base URL' => $request->getUrl(), 'Scheme' => $request->getScheme(), 'Port' => $request->getPort(), 'Host' => $request->getHost()));
                 // Set the title of the error page:
                 $handler->setPageTitle("Bono got whoops! There was a problem.");
             };
             $this->whoops->pushHandler($handler);
             // Add a special handler to deal with AJAX requests with an
             // equally-informative JSON response. Since this handler is
             // first in the stack, it will be executed before the error
             // page handler, and will have a chance to decide if anything
             // needs to be done.
             $this->whoops->pushHandler($jsonResponseHandler);
             $this->whoops->pushHandler($appHandler);
             $this->notFound(array(new NotFoundHandler($this), 'handle'));
             $this->error(array(new ErrorHandler($this), 'handle'));
         }
         $this->config('_handlerConfigured', true);
     }
     return $this;
 }