Exemplo n.º 1
0
 /**
  * Export a Role in a Json file (.rzt).
  *
  * @param Symfony\Component\HttpFoundation\Request $request
  * @param int                                      $roleId
  *
  * @return Symfony\Component\HttpFoundation\Response
  */
 public function exportAction(Request $request, $roleId)
 {
     $this->validateAccessForRole('ROLE_ACCESS_ROLES');
     $existingRole = $this->getService('em')->find('RZ\\Roadiz\\Core\\Entities\\Role', (int) $roleId);
     $serializer = new RoleCollectionJsonSerializer($this->getService('em'));
     $role = $serializer->serialize([$existingRole]);
     $response = new Response($role, Response::HTTP_OK, []);
     $response->headers->set('Content-Disposition', $response->headers->makeDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, 'role-' . $existingRole->getName() . '-' . date("YmdHis") . '.rzt'));
     // Rezo-Zero Type
     $response->prepare($request);
     return $response;
 }
Exemplo n.º 2
0
 /**
  * Import a Json file (.rzt) containing setting and setting group.
  *
  * @param string $serializedData
  *
  * @return bool
  */
 public static function importJsonFile($serializedData)
 {
     RoleCollectionJsonSerializer::deserialize($serializedData);
     return true;
 }
Exemplo n.º 3
0
 /**
  * Import a Json file (.rzt) containing setting and setting group.
  *
  * @param string $serializedData
  * @param EntityManager $em
  *
  * @return bool
  */
 public static function importJsonFile($serializedData, EntityManager $em)
 {
     $serializer = new RoleCollectionJsonSerializer($em);
     $serializer->deserialize($serializedData);
     return true;
 }