@param object $entity

@return string

@throws \RuntimeException
769047
private function getClass($entity)
    {
        if (is_object($entity)) {
            return get_class($entity);
        }

        if (class_exists($entity)) {
            return $entity;
        }

        $realClassName = $this->classnameResolver->resolveFullQualifiedClassname($entity);

        return $realClassName;
    }
1153357
public function getEntityClassFull($entity)
    {
        $entity = $this->toString($entity);

        if (isset($this->cache[$entity])) {
            return $entity;
        }

        if ($this->managed || $this->isManagedByDoctrine($entity)) {
            /** @var \Doctrine\Common\Persistence\Mapping\ClassMetadata $classMetaData */
            $classMetaData        = $this->entityManager->getClassMetadata($entity);
            $entity               = $classMetaData->getName();
            $this->cache[$entity] = ['metadata' => $classMetaData];
            $this->managed        = false;
        } else {
            $this->cache[$entity] = [];
        }

        return $entity;
    }
137459
private function getEntityIdentifierValue($entity)
    {
        $entityMetaData = $this->entityManager->getEntityMetadataRegister()->getEntityMetadata($entity);

        return $entityMetaData ? $entityMetaData->getIdentifierValue() : null;
    }
161491
public function getEntityModel(EntityInterface $entity): string
    {
        $source = $entity->source();
        if (substr($source, -5) == 'Table') {
            $source = substr($source, 0, -5);
        }

        return $source;
    }
940206
private function readClassProperties($entity)
    {
        $className = get_class($entity);
        if (isset($this->entityProperties[$className])) {
            return $this->entityProperties[$className];
        }

        $reflectionClass = new \ReflectionClass($entity);
        $inheritedProperties = array_merge($this->getParentProperties($reflectionClass), $reflectionClass->getProperties());

        $properties = [];
        foreach ($inheritedProperties as $property) {
            $properties[$property->getName()] = $property;
        }

        $this->entityProperties[$className] = $properties;

        return $properties;
    }
297965
private function getMetadata($entity)
    {
        try {
            $metadata = $this->em->getMetadataFactory()->getMetadataFor($entity);
        } catch (MappingException $e) {
            throw new \Exception('getMetadata(): Given object '.$entity.' is not a Doctrine Entity.');
        }

        return $metadata;
    }
401428
public function getEntityClassShort($entity)
    {
        $cacheKey = 'short';
        $entity   = $this->getEntityClassFull($entity);
        $short    = $this->getFromCache($entity, $cacheKey);

        if (false !== $short) {
            return $short;
        }

        foreach ($this->entityManager->getConfiguration()->getEntityNamespaces() as $short => $full) {
            if (false === strpos($entity, $full)) {
                continue;
            }

            $short .= ':'.ltrim(str_replace($full, '', $entity), '\\');
            $this->cache[$full][$cacheKey] = $short;

            return $short;
        }

        return $entity;
    }
936782
private static function getClassMetaData($entity): array
    {
        // 不是对象
        if (!\is_object($entity) && !class_exists($entity)) {
            throw new \InvalidArgumentException('Entity is not an object');
        }

        // 对象实例不是实体
        $entities  = EntityCollector::getCollector();
        $className = \is_string($entity) ? $entity : \get_class($entity);
        if (!isset($entities[$className]['table']['name'])) {
            throw new \InvalidArgumentException('Object is not an entity object, className=' . $className);
        }

        return self::getTable($className);
    }
535096
protected function getIdentifier($entity)
    {
        $entityId = json_decode($this->entityRegistry->getEntityId($entity), true);

        if (is_array($entityId)) {
            $identifier = [];

            foreach ($entityId as $key => $value) {
                $key              = strtolower(Normalise::toUnderscoreSeparated(Normalise::fromCamelCase($key)));
                $identifier[$key] = $value;
            }

            return $identifier;
        }

        $primary = $this->builder->getMeta(get_class($entity))->primary;

        return [$primary => $entityId];
    }
759912
public static function getLinkedEntityName($entity) {
		if (elgg_instanceof($entity)) {
			return elgg_view('output/url', array(
				'text' => $entity->getDisplayName(),
				'href' => $entity->getURL(),
				'is_trusted' => true,
			));
		}
		return '';
	}
275327
public function geocode(Entity $entity) {
		$addressfields = (array)$this->_config['address'];

		$addressData = [];
		$dirty = false;
		foreach ($addressfields as $field) {
			$fieldData = $entity->get($field);
			if ($fieldData) {
				$addressData[] = $fieldData;
			}
			if ($entity->isDirty($field)) {
				$dirty = true;
			}
		}
		if (!$dirty) {
			if ($this->_config['allowEmpty'] || $entity->lat && $entity->lng) {
				return $entity;
			}
			if ($entity instanceof Entity) {
				$this->invalidate($entity);
			}
			return null;
		}

		$result = $this->_geocode($entity, $addressData);
		if (is_array($result)) {
			throw new RuntimeException('Array type not expected');
		}

		return $result;
	}
4098
public function defaultRender($entity)
    {
        $value = (string) $this->getPropertyValue($entity);
        return $this->safeHtml ? $value : htmlspecialchars($value);
    }
251935
public function dcDateIssued($entity)
    {
        if (!$entity->displayMetaDates) {
            return '';
        }
        $published = ($entity->published !== null) ? $entity->published->format('c') : null;
        return $this->_render(self::ATTR_PROP, 'DC.date.issued', $published);
    }
1239132
private function entityToString(EntityInterface $entity)
    {
        $template = "Values: %s";
        $entityValues = null;
        
        foreach ($entity->toArray() as $propertyName => $propertyValue) {
            $entityValues = sprintf("%s\n\t%s = '%s'", $entityValues, $propertyName, $this->stringifyValue($propertyValue));
        }
        
        return sprintf($template, $entityValues);
    }
523286
public function transform($entity) {
    if ($entity === NULL) {
      return NULL;
    }

    $getter = 'get'.ucfirst($this->identifierName);

    return array(
      '__class' => $this->entityClass, // just for verbose
      $this->identifierName => $entity->$getter()
    );
  }
645479
protected function getValue($entity)
    {
        $value = $this->getFieldValue($entity);

        if ($this->formatter) {
            return $this->formatter->formatValue($value);
        }
        else {
            if ($value instanceof \DateTime) {
                $formatter = new DateTimeCellFormatter($this->getDateTimeFormat());
                return $formatter->formatValue($value);
            }
            else {
                return $value;
            }
        }
    }
467947
public function serialize($entity)
    {
        return array($this->getName().'.'.$this->_parent_key => $entity->get($this->_parent_key));
    }