Gets whether or not an entity is registered

@param   object $entity The entity to check

@return  bool  True if the entity is registered, otherwise false
769093
public function isRegistered($entity)
    {
        try {
            $entityId = $this->getEntityId($entity);

            return
                ($this->getEntityState($entity) == EntityStates::REGISTERED)
                || isset($this->entities[$this->getClassName($entity)][$entityId]);
        } catch (OrmException $e) {
            return false;
        }
    }
599878
public function setEntity($entity)
    {
        if ($this->isRegistryEntity(get_class($entity))) {
            $this->classname = get_class($entity);
        }
        $this->entity = $entity;

        return $this;
    }
632465
public function registerEntity(Entity $entity)
    {
        Logger::get()->debug('Registering entity ' . get_class($entity) . ":{$entity->id}...");
        self::$entities[get_called_class()][$entity->id] = $entity;
        Logger::get()->debug('Registered.');
    }
461580
protected function toGUID($entity = null) {
		if ($entity instanceof ElggEntity) {
			return (int) $entity->getGUID();
		} else if ($this->exists($entity)) {
			return (int) $entity;
		}
		return false;
	}
654492
protected function _checkEntity($entity)
    {
        if (!$entity instanceof ArrayAccess && !is_array($entity)) {
            throw new RuntimeException(sprintf(
                'Route `%s` expects the URL option `_entity` to be an array or object implementing \ArrayAccess, but `%s` passed.',
                $this->template,
                getTypeName($entity)
            ));
        }
    }
43860
public function isRegistered($identifier)
    {
        if (false === parent::isRegistered($identifier)) {
            $entity = $this->getContentById($identifier);

            if (!empty($entity)) {
                return true;
            }
        } else {

            return true;
        }

        return false;
    }
46410
protected function checkEntityType($entity)
    {
        if (get_class($entity) != $this->entityMap->getClass() && !is_subclass_of($entity, $this->entityMap->getClass())) {
            $expected = $this->entityMap->getClass();
            $actual = get_class($entity);

            throw new InvalidArgumentException("Expected : $expected, got $actual.");
        }
    }
972118
public function isValidEntity($entity) {
    if ($entity->getEntityTypeId() === 'mentions') {
      return TRUE;
    }

    // Special cases for comments and posts.
    $allowed_content_types = [
      'comment',
    ];
    if (in_array($entity->getEntityTypeId(), $allowed_content_types)) {
      $mentions = $this->getMentionsFromRelatedEntity($entity);
      if (!empty($mentions)) {
        return TRUE;
      }
    }
    return FALSE;
  }
736357
public function register($entity)
    {
        if ($entity instanceof QueryEntityAware) {
            $entity = $entity->getQueryEntity();
        }
        if ($entity instanceof QueryEntity) {
            $name = $entity->getName();
            if ($this->has($name)) {
                throw new RuntimeException("Meta with name \"{$name}\" already exists.");
            }
            $this->meta[$name] = $entity;
        } else {
            throw new InvalidArgumentException('Argument must be instanceof QueryEntityAware or QueryEntity.');
        }
    }
510063
public function isOdm($entity)
    {
        $annotation = $this->getClassAnnotation($entity, 'Doctrine\ODM\MongoDB\Mapping\Annotations\Document');

        if ($annotation === null) {
            return false;
        }

        return true;
    }
364441
public function hasChanged($entity)
    {
        $hashId = $this->getHashId($entity);

        if (!isset($this->originalData[$hashId])) {
            throw new OrmException("Entity is not registered");
        }

        if (isset($this->comparators[get_class($entity)])) {
            return $this->hasChangedUsingComparisonFunction($entity);
        }

        return $this->hasChangedUsingReflection($entity);
    }
835748
private function updateEntity($entity)
    {
        $change = false;

        $propertyAccessor = PropertyAccess::createPropertyAccessor();
        $targetProperty = $propertyAccessor->getValue($entity, $this->targetProperty);

        // if entity state is still proxy, we try to load its entity to make sure that target property is correct
        if($entity instanceof Proxy && $targetProperty === null) {
            $this->loadEntity($entity);
            $targetProperty = $propertyAccessor->getValue($entity, $this->targetProperty);
        }

        if($targetProperty) {
            // update id property
            $idProperty = $propertyAccessor->getValue($entity, $this->idProperty);
            $id = $propertyAccessor->getValue($targetProperty, 'id');
            if($idProperty != $id) {
                $propertyAccessor->setValue($entity, $this->idProperty, $id);
                $change = true;
            }

            // update class property
            $classProperty = $propertyAccessor->getValue($entity, $this->classProperty);
            $class = $this->targetClassResolver->resolveClass($targetProperty);
            if($classProperty != $class) {
                $propertyAccessor->setValue($entity, $this->classProperty, $class);
                $change = true;
            }
        } else {
            if(null !== $propertyAccessor->getValue($entity, $this->idProperty)) {
                $propertyAccessor->setValue($entity, $this->idProperty, null);
                $change = true;
            }

            if(null !== $propertyAccessor->getValue($entity, $this->classProperty)) {
                $propertyAccessor->setValue($entity, $this->classProperty, null);
                $change = true;
            }
        }

        return $change;
    }
1328603
private function isScheduledForDelete($entity)
    {
        $originalClassName = ClassUtils::getClass($entity);

        return isset($this->toBeDeleted[$originalClassName]) && isset($this->toBeDeleted[$originalClassName][spl_object_hash($entity)]);
    }
536796
public function getLevel($entity)
    {
        $primaryKey = $this->_getPrimaryKey();
        $id = $entity;
        if ($entity instanceof EntityInterface) {
            $id = $entity->get($primaryKey);
        }
        $config = $this->getConfig();
        $entity = $this->_table->find('all')
            ->select([$config['left'], $config['right']])
            ->where([$primaryKey => $id])
            ->first();

        if ($entity === null) {
            return false;
        }

        $query = $this->_table->find('all')->where([
            $config['left'] . ' <' => $entity[$config['left']],
            $config['right'] . ' >' => $entity[$config['right']],
        ]);

        return $this->_scope($query)->count();
    }
880955
public function isEntity(string $className): bool
    {
        return class_exists($className) && !$this->entityManager->getMetadataFactory()->isTransient($className);
    }
131651
private function process($entity)
    {
        $entityClass = get_class($entity);

        if (false === ($entity instanceof HasOptionalFieldsEntityInterface)) {
            return false;
        }

        $reflectionClass = new \ReflectionClass($entityClass);
        foreach ($reflectionClass->getProperties() as $reflectionProperty) {
            /** @var Optional $propertyAnnotation */
            $propertyAnnotation = $this->getReader()->getPropertyAnnotation($reflectionProperty, Optional::class);
            if (null === $propertyAnnotation) {
                continue;
            }

            $default = $this->getDefault($reflectionProperty, $propertyAnnotation->default);
            $reflectionProperty->setAccessible(true);

            if (null === $reflectionProperty->getValue($entity)) {
                $reflectionProperty->setValue($entity, $default);
            }
        }

        return true;
    }
649483
protected function storeEntity($entity)
    {
        $this->checkEntityType($entity);

        $store = new Store($this->aggregate($entity), $this->newQueryBuilder());

        return $store->execute();
    }