/** * @param $entity * @param $group * @return mixed */ public function extractEntity($entity, $group) { $serializedContext = SerializationContext::create()->setGroups(array($group))->setSerializeNull(true); return $this->transformer->transformExtractData(json_decode($this->serializer->serialize($entity, 'json', $serializedContext), true)); }
/** * @param $data * @param $entityName * @return mixed */ public function hydrateEntity($data, $entityName) { return $this->serializer->deserialize($this->transformer->transformHydrateData($data), $entityName, 'json'); }