PartKeepr\CategoryBundle\Action\MoveAction::__invoke PHP Method

__invoke() public method

Retrieves a collection of resources.
public __invoke ( Request $request, $id ) : array | Dunglas\ApiBundle\Model\PaginatorInterface | Traversable
$request Symfony\Component\HttpFoundation\Request
return array | Dunglas\ApiBundle\Model\PaginatorInterface | Traversable
    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'));
    }