protected function loadItem($em, $data, $attributes, $association)
    {
        if (is_object($data)) {
            if (get_class($data) === 'DateTime') {
                return array('type' => 'DateTime', 'name' => $data->format('r'));
            }

            if (array_key_exists('targetEntity', $attributes)) {
                $targetClass = $em->getClassMetadata($attributes['targetEntity']);

//                var_dump($association);die();
                $className = get_class($data);

//                die($className);
                $entityProvider = new EntityProvider($className);

//                $meta = $em->getClassMetadata($className);
                $identifier = $targetClass->getSingleIdentifierFieldName();
                $identifierMethodName = 'get'.ucfirst($identifier);

                return array(
                    'type' => 'reference',
                    'name' => $entityProvider->getName().'_'.$data->$identifierMethodName(),
                );
            }

            throw new \Exception('Unknown data class: '.get_class($data));
        }

        if (!is_array($data)) {
            return str_replace(array("\r\n",   "\r", "\n"), '\n', htmlspecialchars($data, ENT_QUOTES));
        }

        return $data;
    }