Ejemplo n.º 1
0
 /**
  * Import a Json file (.rzt) containing tag and tag translation.
  *
  * @param string $serializedData
  * @param EntityManager $em
  *
  * @return bool
  */
 public static function importJsonFile($serializedData, EntityManager $em)
 {
     $serializer = new TagJsonSerializer();
     $tags = $serializer->deserialize($serializedData);
     $exist = $em->getRepository('RZ\\Roadiz\\Core\\Entities\\Tag')->findAll();
     if (empty($exist)) {
         foreach ($tags as $tag) {
             static::browseTree($tag, $em);
         }
     }
     return true;
 }
Ejemplo n.º 2
0
 /**
  * Export a Tag in a Json file (.rzn).
  *
  * @param Symfony\Component\HttpFoundation\Request $request
  * @param int                                      $tagId
  *
  * @return Symfony\Component\HttpFoundation\Response
  */
 public function exportAllAction(Request $request, $tagId)
 {
     $this->validateAccessForRole('ROLE_ACCESS_TAGS');
     $existingTags = $this->getService('em')->getRepository('RZ\\Roadiz\\Core\\Entities\\Tag')->findBy(["parent" => null]);
     foreach ($existingTags as $existingTag) {
         $this->getService('em')->refresh($existingTag);
     }
     $serializer = new TagJsonSerializer();
     $tag = $serializer->serialize($existingTags);
     $response = new Response($tag, Response::HTTP_OK, []);
     $response->headers->set('Content-Disposition', $response->headers->makeDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, 'tag-all-' . date("YmdHis") . '.rzg'));
     // Rezo-Zero Type
     $response->prepare($request);
     return $response;
 }
Ejemplo n.º 3
0
 /**
  * Import a Json file (.rzt) containing tag and tag translation.
  *
  * @param string $serializedData
  *
  * @return bool
  */
 public static function importJsonFile($serializedData)
 {
     $tags = TagJsonSerializer::deserialize($serializedData);
     $exist = Kernel::getInstance()->getService('em')->getRepository('RZ\\Roadiz\\Core\\Entities\\Tag')->findAll();
     if (empty($exist)) {
         foreach ($tags as $tag) {
             static::browseTree($tag);
         }
     }
     return true;
 }