示例#1
0
 public function testAbsoluteUrlGetsRouteAndAppendsPortWhenNotStandard()
 {
     $uri = SlimUri::createFromString('http://host:8443/path/page?query=1');
     $this->router->shouldReceive('relativePathFor')->with('route.name', ['param1' => '1'], [])->andReturn('/test-route-page');
     $url = new URI($this->router);
     $actual = $url->absoluteURIFor($uri, 'route.name', ['param1' => '1']);
     $this->assertSame('http://host:8443/test-route-page', $actual);
 }
 /**
  * {@inheritdoc}
  */
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response)
 {
     $alert = '';
     $error = $this->uri->getQueryParam($request->getUri(), 'type');
     if ($error) {
         $isValidError = $this->throwError($error);
         if ($isValidError) {
             $alert = sprintf('<p class="alert">Error triggered: %s</p>', $error);
         }
     }
     $rendered = str_replace('{triggered}', $alert, self::HTML);
     $response->getBody()->write($rendered);
     return $response;
 }
 /**
  * @param string $route
  * @param string $title
  * @param string $src
  *
  * @return string
  */
 private function formatPage($route, $title, $src)
 {
     return sprintf(self::PAGE_ROW, $this->uri->uriFor($route, ['id' => 313]), $title, $src);
 }