public function deserialize($data, $entity)
    {
        if (!$this->container->has('hydra.serializer')) {
            throw new \LogicException('The HydraBundle is not registered in your application.');
        }

        $serializer = $this->container->get('hydra.serializer');

        if (is_object($entity)) {
            return $serializer->deserializeIntoEntity($data, $entity);
        }

        return $serializer->deserialize($data, $entity, self::FORMAT);
    }