Determines whether an entity instance is managed in this EntityManager.

@param object $entity

@return bool TRUE if this EntityManager currently manages the given entity, FALSE otherwise.
972401
public function contains($entity)
    {
        return $this->unitOfWork->isScheduledForInsert($entity)
            || ($this->unitOfWork->isInIdentityMap($entity) && ! $this->unitOfWork->isScheduledForDelete($entity));
    }
1047850
public function removeEntity($entity)
    {
        $registries = $this->findRegistriesEntityById(get_class($entity), $entity->getObjectIdentifier());

        foreach ($registries as $registry) {
            $this->remove($registry);
        }
    }
1290820
public function isScheduledForDirtyCheck($entity) : bool
    {
        $rootEntityName = $this->em->getClassMetadata(get_class($entity))->getRootClassName();

        return isset($this->scheduledForSynchronization[$rootEntityName][spl_object_id($entity)]);
    }
1049834
public function findByEntityInstance($entity)
    {
        $businessEntity = null;
        $class = new \ReflectionClass($entity);
        while (!$businessEntity && $class && $class->name !== null) {
            $businessEntity = $this->findByEntityClassname($class->name);
            $class = $class->getParentClass();
        }

        return $businessEntity;
    }
426945
public function isSatisfiedBy(Entity $entity)
    {
        if (property_exists($entity, 'active')) {
            return (bool)$entity->active;
        }

        throw new InvalidArgumentException("Property 'active' does not exist in class " . get_class($entity));
    }
427746
public function save($entity)
    {
        $this
            ->objectManager
            ->persist($entity);

        $this
            ->objectManager
            ->flush($entity);
    }
830237
public function delete($entity) {
        $deleteQuerys = $this->buildDeleteQuery($entity);
        foreach (explode(";", $deleteQuerys) as $q) {
            if (strlen($q) > 5)
                $this->conn->executeNonQuery($q);
        }
        return true;
    }
1349436
public function saveEntity($entity)
    {
        if (!$this->entityManager->contains($entity)) {
            $this->entityManager->persist($entity);
        }

        $this->entityManager->flush();
        return true;
    }
231047
public function created(Model $entity)
    {
        $data = [
            'database' => $this->getConnectionName(),
            'driver' => $this->getDriverName(),
        ];

        $this->dispatch($this->getCreateTenantJob($entity, $data));

        return true;
    }
1042196
private function hasInDecodedRegistry($entity, EntityManager $em) {
        $className = get_class($entity);
        $metadata = $em->getClassMetadata($className);
        $getter = 'get' . self::capitalize($metadata->getIdentifier());

        return isset($this->decodedRegistry[$className][$entity->$getter()]);
    }
998201
public function store($entity)
    {
        if ($this->manager->isTraversable($entity)) {
            return $this->storeCollection($entity);
        } else {
            return $this->storeEntity($entity);
        }
    }
1359596
public function remove($entity)
    {
        $objectManager = $this->getObjectManager();
        $objectManager->remove($entity);
        $objectManager->flush();
    }
38093
public function flush($entity = null)
    {
        if ($entity !== null) {
            $this->persist($entity);
        }

        return $this->getEntityManager()->flush();
    }
891495
public function save($entity)
    {
        $query = new Query($entity, false);
        $structure = $this->getEntityStructure($entity);

        if ($entity->_saved) {
            // Update
            $result = $query->update()->set($this->getEntityDataArray($entity))->where(array($structure->primaryColumn->name => $entity->_id))->apply();

            // Update relations
            RelationManager::with($entity)->saveRelations();

            return $result;
        } else {
            // Insert
            $id = $query->insert()->into($structure->tableName)->values($this->getEntityDataArray($entity))->apply();

            if ($id === false) {
                return false; // @codeCoverageIgnore
            }

            // Update relations
            RelationManager::with($entity)->saveRelations();

            // Save ID and state
            $entity->{$structure->primaryColumn->propertyName} = $id;
            $entity->_id = $id;
            $entity->_saved = true;

            return true;
        }
    }
239496
protected function _deleteFromTree($entity) {
		extract($this->_config);

		$span = 1;
		if ($entity->$right - $entity->$left !== 1) {
			$span = $entity->$right - $entity->$left;
			$model::remove([$parent => $entity->data($model::key())]);
		}
		$this->_update($entity->$right, '-', $span + 1, $this->_scope($entity));
		return true;
	}
396127
public function isInIdentityMap($entity)
    {
        $oid = spl_object_hash($entity);
        return isset($this->scheduledForPersist[$oid]) || isset($this->scheduledForDelete[$oid]);
    }
301438
public function isInIdentityMap($entity)
    {
        $oid = spl_object_hash($entity);
        if ( ! isset($this->entityIdentifiers[$oid])) {
            return false;
        }
        $classMetadata = $this->xem->getClassMetadata(get_class($entity));
        $id = $this->entityIdentifiers[$oid];
        if ($id === '') {
            return false;
        }

        return isset($this->identityMap[$classMetadata->rootXmlEntityName][$id]);
    }