fromString() public static méthode

Internally, casts the message to a stream and invokes fromStream().
public static fromString ( string $message ) : Request
$message string
Résultat Zend\Diactoros\Request
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next)
 {
     if ($request->getMethod() === 'POST') {
         $parsedBody = $this->parseBody($request->getBody());
         if (is_array($parsedBody) && isset($parsedBody[self::PARAM])) {
             $requestToSimulate = $parsedBody[self::PARAM];
             $deserializedRequest = RequestSerializer::fromString($requestToSimulate);
             $request = new ServerRequest($request->getServerParams(), $request->getUploadedFiles(), $deserializedRequest->getUri(), $deserializedRequest->getMethod(), $deserializedRequest->getBody(), $deserializedRequest->getHeaders());
         }
     }
     $requestAsString = RequestSerializer::toString($request);
     $responseResult = $next($request, $response);
     $responseAsString = ResponseSerializer::toString($responseResult);
     $html = sprintf($this->getHtmlTemplate(), self::PARAM, $requestAsString, $responseAsString);
     return new HtmlResponse($html);
 }
Exemple #2
0
 public function unserialize($serialized)
 {
     $data = unserialize($serialized);
     $this->requestData = $data['requestData'];
     if (isset($data['request'])) {
         $this->request = \Zend\Diactoros\Request\Serializer::fromString($data['request']);
     }
     if (isset($data['response'])) {
         $this->response = \Zend\Diactoros\Response\Serializer::fromString($data['response']);
     }
 }