public function toggleAction(Request $request, AbstractAdmin $admin)
    {
        $id = $request->attributes->get('id');
        $entity = $this->getDoctrine()->getRepository($admin->getEntityClass())->find($id);

        if (!$entity) {
            throw $this->createNotFoundException('The resource cannot be found');
        }

        $this->secure($admin, ContentVoter::UPDATE_CONTENT, $entity);
        $this->checkCsrf($request->attributes->get('token'));

        $field = $request->attributes->get('field');

        // Get current entity property value
        $accessor = PropertyAccess::createPropertyAccessor();
        $current = $accessor->getValue($entity, $field);
        // Update it to its contrary
        $accessor->setValue($entity, $field, !$current);

        try {
            // Apply
            $em = $this->getDoctrine()->getManager();
            $em->persist($entity);
            $em->flush();

            return new JsonResponse(!$current, 200);
        } catch (Exception $e) {
            // return json response
            return new JsonResponse($current, 500);
        }
    }