Esempio n. 1
0
 protected function createHtmlReport($exception)
 {
     $actionView = new ActionView();
     $actionView->lookupContext()->addPath(__DIR__ . '/templates');
     $assigns = new Assigns(['application' => $this->application, 'exception' => $exception]);
     $helperSet = new HelperSet();
     $helperSet->addHelper(new ReporterHelper($helperSet));
     $presenter = new ExceptionPresenter($helperSet);
     $helperSet->invoke('setPresenter', [$presenter]);
     $renderParams = ['partial' => false, 'layout' => 'layout', 'prefixes' => [], 'details' => ['locale' => [], 'handlers' => ['php'], 'formats' => []], 'assigns' => $assigns, 'helperSet' => $helperSet];
     $contents = [];
     $contents[] = $this->renderException($exception, $actionView, $presenter, $renderParams);
     if ($previous = $exception->getPrevious()) {
         while ($previous) {
             $contents[] = $this->renderException($previous, $actionView, $presenter, $renderParams);
             $previous = $previous->getPrevious();
         }
     }
     return implode("\n", $contents);
 }
Esempio n. 2
0
 public static function dispatchRequest($app)
 {
     $actionView = new ActionView();
     $actionView->lookupContext()->addPath(__DIR__ . '/templates');
     $actionView->lookupContext()->addPath(__DIR__ . '/../../ActionDispatch/ErrorReporting/templates');
     $assigns = new Assigns(['routes' => $app->routes()]);
     $helperSet = new HelperSet($app->request(), $app->parameters());
     $helperSet->setRouteSet($app->routes());
     $actionView->setHelperSet($helperSet);
     $presenter = new RoutePresenter($helperSet);
     $helperSet->invoke('setPresenter', [$presenter]);
     switch ($app->parameters()->action) {
         case 'routes':
             $contents = $actionView->renderTemplate('routes', ['partial' => false, 'layout' => 'layout', 'prefixes' => [], 'assigns' => $assigns, 'helperSet' => $helperSet, 'details' => ['locale' => [], 'handlers' => ['php'], 'formats' => []]]);
             $app->response()->setBody($contents);
             break;
         default:
             $app->response()->setLocation($app->routes()->pathFor('railsInfo', ['action' => 'routes']));
             break;
     }
 }
Esempio n. 3
0
 /**
  * If after calling actionView(), helper() is called, those
  * helpers won't be added to the HelperSet.
  */
 public function actionView()
 {
     if (!$this->actionView) {
         $this->actionView = new ActionView();
         # TODO: add default helpers.
         # make sure namespaced controllers get namespaced helpers added.
         HelperSet::addDefaultHelper('ApplicationHelper');
         $this->actionView->setHelperSet(new HelperSet($this->request(), $this->params(), $this->session(), $this->assigns()));
         # Set routeSet to baseHelper.
         $this->actionView->helperSet()->setRouteSet($this->routeSet());
     }
     return $this->actionView;
 }