Beispiel #1
0
 /**
  * @param WebRequest $request
  * @return Url
  */
 private function getAbsoluteTarget(WebRequest $request)
 {
     $target = $this->getTarget();
     if ($target->isAbsolute()) {
         return $target;
     }
     return Url::fromString($request->getContext() . '/' . $target);
 }
Beispiel #2
0
 public function getBody()
 {
     $userMessage = '';
     if ($this->exception instanceof HttpError) {
         $userMessage = $this->exception->getUserMessage();
     }
     if ($this->request->getFormats()->contains('html')) {
         $model = array('status' => $this->getStatus(), 'rootUrl' => $this->request->getContext()->toString(), 'userMessage' => $userMessage);
         $details = date('Y-m-d H:i:s');
         $exception = $this->exception;
         while ($exception) {
             $details .= "\n" . get_class($exception) . ": " . $exception->getMessage() . "\n" . $exception->getTraceAsString() . "\n";
             $exception = $exception->getPrevious();
         }
         $model['details'] = htmlentities($details);
         return $this->renderTemplate($model);
     } else {
         return $userMessage ?: get_class($this->exception) . ': ' . $this->exception->getMessage();
     }
 }
Beispiel #3
0
 private function getTarget(WebRequest $request)
 {
     return (string) $request->getContext()->appended($this->actionId)->withParameters(new Map($this->parameters));
 }
Beispiel #4
0
 private function wrapTarget($target, $name, $next, WebRequest $request)
 {
     $targetUrl = Url::fromString($target);
     if ($targetUrl->isAbsolute()) {
         $context = $request->getContext()->toString();
         $target = ltrim(substr($target, strlen($context)), '/');
     }
     $model = '<a href="' . $target . '"/>';
     $wrapped = $this->wrap($name, $model, $next, $request);
     $wrappedTarget = Url::fromString(substr($wrapped, 9, -3));
     foreach ($request->getArguments() as $key => $value) {
         if ($key != Wrapper::$PREFIX . $name) {
             $wrappedTarget->getParameters()->set($key, $value);
         }
     }
     return $wrappedTarget->toString();
 }
Beispiel #5
0
 private function updateCrumbs($actionId, ExecutionResult $result, WebRequest $request, ParameterReader $reader)
 {
     $action = $this->app->actions->getAction($actionId);
     $crumbs = $this->readCrumbs();
     $current = ['target' => (string) $request->getContext()->appended($actionId)->withParameters(new Map($this->readRawParameters($action, $reader))), 'caption' => $action->caption()];
     $newCrumbs = [];
     foreach ($crumbs as $crumb) {
         if ($crumb == $current) {
             break;
         }
         $newCrumbs[] = $crumb;
     }
     $newCrumbs[] = $current;
     if ($result instanceof RenderedResult) {
         $this->saveCrumbs($newCrumbs);
     }
     return $newCrumbs;
 }
Beispiel #6
0
 public function prepare(WebRequest $request)
 {
     $this->registerRenderers($request->getContext());
     $this->registerFields();
     $this->actions->restrictAccess($this->getAccessControl($request));
 }