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);
    }