Sets the dispatched flag
public setDispatched ( boolean $flag ) : void | ||
$flag | boolean | If this request has been dispatched |
Résultat | void |
/** * @test */ public function setDispatchedEmitsSignalIfDispatched() { $mockDispatcher = $this->createMock(Dispatcher::class); $mockDispatcher->expects($this->once())->method('dispatch')->with(ActionRequest::class, 'requestDispatched', [$this->actionRequest]); $mockObjectManager = $this->createMock(ObjectManagerInterface::class); $mockObjectManager->expects($this->any())->method('get')->will($this->returnValue($mockDispatcher)); $this->inject($this->actionRequest, 'objectManager', $mockObjectManager); $this->actionRequest->setDispatched(true); }
/** * Initializes the controller * * This method should be called by the concrete processRequest() method. * * @param RequestInterface $request * @param ResponseInterface $response * @throws UnsupportedRequestTypeException */ protected function initializeController(RequestInterface $request, ResponseInterface $response) { if (!$request instanceof ActionRequest) { throw new UnsupportedRequestTypeException(get_class($this) . ' only supports action requests – requests of type "' . get_class($request) . '" given.', 1187701131); } $this->request = $request; $this->request->setDispatched(true); $this->response = $response; $this->uriBuilder = new UriBuilder(); $this->uriBuilder->setRequest($this->request); $this->arguments = new Arguments([]); $this->controllerContext = new ControllerContext($this->request, $this->response, $this->arguments, $this->uriBuilder); $mediaType = $request->getHttpRequest()->getNegotiatedMediaType($this->supportedMediaTypes); if ($mediaType === null) { $this->throwStatus(406); } if ($request->getFormat() === null) { $this->request->setFormat(MediaTypes::getFilenameExtensionFromMediaType($mediaType)); } }