Exemplo n.º 1
0
 /**
  * Export all settings in a Json file (.rzt).
  *
  * @param Symfony\Component\HttpFoundation\Request $request
  *
  * @return Symfony\Component\HttpFoundation\Response
  */
 public function exportAllAction(Request $request)
 {
     $this->validateAccessForRole('ROLE_ACCESS_SETTINGS');
     $groups = $this->getService('em')->getRepository('RZ\\Roadiz\\Core\\Entities\\SettingGroup')->findAll();
     $lonelySettings = $this->getService('em')->getRepository('RZ\\Roadiz\\Core\\Entities\\Setting')->findBy(['settingGroup' => null]);
     $tmpGroup = new SettingGroup();
     $tmpGroup->setName('__default__');
     $tmpGroup->addSettings($lonelySettings);
     $groups[] = $tmpGroup;
     $data = SettingCollectionJsonSerializer::serialize($groups);
     $response = new Response($data, Response::HTTP_OK, []);
     $response->headers->set('Content-Disposition', $response->headers->makeDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, 'setting-all-' . date("YmdHis") . '.rzt'));
     // Rezo-Zero Type
     $response->prepare($request);
     return $response;
 }