public function __invoke(Request $request, $id)
{
list($resourceType) = $this->extractAttributes($request);
$entity = $this->getItem($this->dataProvider, $resourceType, $id);
$parentId = $request->request->get('parent');
$parentEntity = $this->iriConverter->getItemFromIri($parentId);
if ($parentEntity === null) {
throw new MissingParentCategoryException($parentId);
}
if ($entity->getLevel() === 0) {
throw new RootMayNotBeMovedException();
}
$entity->setParent($parentEntity);
$this->registry->getManager()->flush();
return new Response($request->request->get('parent'));
}