public function __construct(Request $request, Response $response, DB $db) { $this->request = $request; $this->response = $response; $this->db = $db; if (!$request->withMethod('POST')) { die('Not allowed'); } }
/** * {@inheritdoc} */ public function withMethod($method) { return new static($this->wrapped->withMethod($method)); }
/** * {@inheritDoc} */ public function withMethod($method) { return new self($this->app, $this->psrRequest->withMethod($method)); }
/** * Proxy to ServerRequestInterface::withMethod() * * {@inheritdoc} */ public function withMethod($method) { $new = $this->psrRequest->withMethod($method); return new self($new, $this->originalRequest); }
/** * @inheritDoc */ public function withMethod($method) { $self = clone $this; $self->serverRequest = $this->serverRequest->withMethod($method); return $self; }
/** * @param \Psr\Http\Message\ServerRequestInterface $request * @return \Psr\Http\Message\ServerRequestInterface */ protected function applyVirtualMethod(ServerRequestInterface $request) { if (!$this->config->isVirtualMethodEnabled()) { return $request; } $parsedBody = $request->getParsedBody(); if (!isset($parsedBody['_method'])) { return $request; } return $request->withMethod(strtoupper($parsedBody['_method'])); }