/** * Export a content type in Json format * * @param integer $id * @param Request $request * @Route("/content-type/export/{contentType}.{_format}", defaults={"_format" = "json"}, name="contenttype.export")) */ public function exportAction(ContentType $contentType, Request $request) { //Sanitize the CT $contentType->setCreated(NULL); $contentType->setModified(NULL); $contentType->getFieldType()->removeCircularReference(); $contentType->setEnvironment(NULL); //$contentType->getTemplates()->clear(); //$contentType->getViews()->clear(); //Serialize the CT $encoders = array(new JsonEncoder()); $normalizers = array(new JsonNormalizer()); $serializer = new Serializer($normalizers, $encoders); $jsonContent = $serializer->serialize($contentType, 'json'); $response = new Response($jsonContent); $diposition = $response->headers->makeDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $contentType->getName() . '.json'); $response->headers->set('Content-Disposition', $diposition); return $response; }