/**
  * Serializer
  * 
  * @param  array  $dataArray    -Data array which needs to be serialized
  * @param  string $outputFormat -Serialization format
  * 
  * @return multiple $serializedData
  */
 protected function serialize($dataArray, $outputFormat = "json")
 {
     if ("json" == $outputFormat) {
         $serializer = $this->getServiceLocator()->get('jms_serializer.serializer');
         $context = new \JMS\Serializer\SerializationContext();
         $context->setSerializeNull(true);
         $context->enableMaxDepthChecks();
         $serializedData = $serializer->serialize($dataArray, $outputFormat, $context);
     } else {
         // TODO : Add XML support
     }
     //$serializedData = json_decode($serializedData, true);
     return $serializedData;
 }
Ejemplo n.º 2
0
 public function serialize(array $data = [], $format = 'json')
 {
     $context = new \JMS\Serializer\SerializationContext();
     $context->setSerializeNull(true);
     return $this->serializer->serialize($data, $format, $context);
 }