src/Zf2FileUploader/Controller/AbstractRemoveController.php
public function dispatch(Request $request, Response $response = null)
    {
        $this->resourceEntity = $this->getRepository()->findOneByToken($this->params()
                                                                            ->fromRoute(static::REMOVE_ROUTE_PARAM));

        if (is_null($this->resourceEntity)) {
            $response = $response ?: new HttpResponse();
            $this->getEventManager()->clearListeners(MvcEvent::EVENT_DISPATCH);
            $response->setStatusCode(404);
        }

        parent::dispatch($request, $response);
    }
public function dispatch(Request $request, Response $response = null)
    {
        $this->resourceEntity = $this->getRepository()->findOneByToken($this->params()
                                                                            ->fromRoute(static::REMOVE_ROUTE_PARAM));

        if (is_null($this->resourceEntity)) {
            $response = $response ?: new HttpResponse();
            $this->getEventManager()->clearListeners(MvcEvent::EVENT_DISPATCH);
            $response->setStatusCode(404);
        }

        parent::dispatch($request, $response);
    }
Dispatch a request

@events dispatch.pre, dispatch.post
@param  Request $request
@param  null|Response $response
@return Response|mixed