public function deserializeEntity(array $data, $entityOrClass)
    {
        $context = null;
        if (is_object($entityOrClass)) {
            $context = DeserializationContext::create();
            $context->attributes->set('target', $entityOrClass);
            $context->enableMaxDepthChecks(true);
            $entityOrClass = get_class($entityOrClass);
        }

        return $this->getSerializer()->deserialize(json_encode($data), $entityOrClass, 'json',  $context);
    }