/**
  * @param  MediaFolder $mediaFolder
  * @param  Request     $request
  * @return Response
  *
  * @ParamConverter(name="mediaFolder", class="BackBee\NestedNode\MediaFolder")
  * @Rest\Security("is_fully_authenticated() & has_role('ROLE_API_USER') & is_granted('EDIT', mediaFolder)")
  */
 public function patchAction(MediaFolder $mediaFolder, Request $request)
 {
     $operations = $request->request->all();
     try {
         (new OperationSyntaxValidator())->validate($operations);
     } catch (InvalidOperationSyntaxException $e) {
         throw new BadRequestHttpException('operation invalid syntax: ' . $e->getMessage());
     }
     $this->patchSiblingAndParentOperation($mediaFolder, $operations);
     $entityPatcher = new EntityPatcher(new RightManager($this->getSerializer()->getMetadataFactory()));
     try {
         $entityPatcher->patch($mediaFolder, $operations);
     } catch (UnauthorizedPatchOperationException $e) {
         throw new BadRequestHttpException('Invalid patch operation: ' . $e->getMessage());
     }
     $this->getEntityManager()->flush();
     return $this->createJsonResponse(null, 204);
 }
 /**
  * Patch page.
  *
  * @return \Symfony\Component\HttpFoundation\Response
  *
  * @Rest\RequestParam(name="0", description="Patch operations", requirements={
  *   @Assert\NotBlank(message="Request must contain at least one operation")
  * })
  *
  * @Rest\Security(expression="is_granted('EDIT', page)")
  */
 public function patchAction(Request $request, $uid)
 {
     //     * @ParamConverter(name="page", class="BackBee\CoreDomain\NestedNode\Page")
     $page = $this->getEntity('BackBee\\CoreDomain\\NestedNode\\Page', $uid);
     $operations = $request->request->all();
     try {
         (new OperationSyntaxValidator())->validate($operations);
     } catch (InvalidOperationSyntaxException $e) {
         throw new BadRequestHttpException('operation invalid syntax: ' . $e->getMessage());
     }
     $entity_patcher = new EntityPatcher(new RightManager($this->getSerializer()->getMetadataFactory()));
     $entity_patcher->getRightManager()->addAuthorizationMapping($page, array('publishing' => array('replace'), 'archiving' => array('replace')));
     $this->patchStateOperation($page, $operations);
     $this->patchSiblingAndParentOperation($page, $operations);
     try {
         $entity_patcher->patch($page, $operations);
     } catch (UnauthorizedPatchOperationException $e) {
         throw new BadRequestHttpException('Invalid patch operation: ' . $e->getMessage());
     }
     if (true === $page->isOnline(true)) {
         $this->granted('PUBLISH', $page);
     }
     $this->getDoctrine()->getManager()->flush();
     return $this->createJsonResponse(null, 204);
 }
 /**
  * Patch the bundle.
  *
  * @Rest\RequestParam(name="0", description="Patch operations", requirements={
  *   @Assert\NotBlank(message="Request must contain at least one operation")
  * })
  *
  * @param string $id the id of the bundle we are looking for
  */
 public function patchAction($id, Request $request)
 {
     $bundle = $this->getBundleById($id);
     $this->granted('EDIT', $bundle);
     $operations = $request->request->all();
     try {
         (new OperationSyntaxValidator())->validate($operations);
     } catch (InvalidOperationSyntaxException $e) {
         throw new BadRequestHttpException('operation invalid syntax: ' . $e->getMessage());
     }
     $entity_patcher = new EntityPatcher(new RightManager($this->getSerializer()->getMetadataFactory()));
     $entity_patcher->getRightManager()->addAuthorizationMapping($bundle, array('category' => array('replace'), 'config_per_site' => array('replace'), 'enable' => array('replace')));
     try {
         $entity_patcher->patch($bundle, $operations);
     } catch (UnauthorizedPatchOperationException $e) {
         throw new BadRequestHttpException('Invalid patch operation: ' . $e->getMessage());
     }
     $this->getApplication()->getContainer()->get('config.persistor')->persist($bundle->getConfig(), null !== $bundle->getConfig()->getProperty('config_per_site') ? $bundle->getConfig()->getProperty('config_per_site') : false);
     return $this->createJsonResponse(null, 204);
 }