/** * Returns an item to delete. * * @param Request $request * @param string|int $id * * @return mixed * * @throws NotFoundHttpException * @throws RuntimeException * @throws UserProtectedException */ public function __invoke(Request $request, $id) { list($resourceType) = $this->extractAttributes($request); /** * @var User $item */ $item = $this->getItem($this->dataProvider, $resourceType, $id); if ($item->isProtected()) { throw new UserProtectedException(); } $this->userService->deleteFOSUser($item); return $item; }