Checks whether an entity is scheduled for insertion, update or deletion.

@param object $entity

@return bool
974284
public function isEntityScheduled($entity)
    {
        $oid = spl_object_id($entity);

        return isset($this->entityInsertions[$oid])
            || isset($this->entityUpdates[$oid])
            || isset($this->entityDeletions[$oid]);
    }
412354
protected function _checkEntityBeforeSave(EntityInterface &$entity) {
		if ($entity->isNew()) {
			if (!$entity->has('model')) {
				$entity->set('model', $this->_table->getTable());
			}

			if (!$entity->has('adapter')) {
				$entity->set('adapter', $this->getConfig('defaultStorageConfig'));
			}

			$fileHashMethod = $this->getConfig('getFileHash');
			if ($fileHashMethod) {
				if ($fileHashMethod === true) {
					$fileHashMethod = 'sha1';
				}
				$entity->set('hash', StorageUtils::getFileHash($entity->get('file')['tmp_name'], $fileHashMethod));
			}
		}
	}
286760
public function scheduleForSynchronization($entity)
    {
        $rootClassName = $this->em->getClassMetadata(get_class($entity))->getRootClassName();

        $this->scheduledForSynchronization[$rootClassName][spl_object_id($entity)] = $entity;
    }
109818
public function insertEntity(EntityInterface $entity)
    {
        $insert = $this->getSql()->insert();
        $insert->values($this->getHydrator()->extract($entity));

        try {
            $this->insertWith($insert);
        } catch (RuntimeException $e) {
            return false;
        }

        return true;
    }
479209
public function persist(Entity $entity)
    {
        $this->checkEntityType($entity);

        $this->events->invokeCallbacks(Events::EVENT_BEFORE_PERSIST, $entity);
        if ($entity->isDetached()) {
            $entity->makeAlive($this->entityFactory, $this->connection, $this->mapper);
            $this->events->invokeCallbacks(Events::EVENT_BEFORE_CREATE, $entity);
            $result = $id = $this->insertIntoDatabase($entity);
            $entity->attach($id);
            $this->events->invokeCallbacks(Events::EVENT_AFTER_CREATE, $entity);
        } else {
            if ($entity->isModified()) {
                $this->events->invokeCallbacks(Events::EVENT_BEFORE_UPDATE, $entity);
                $result = $this->updateInDatabase($entity);
                $this->events->invokeCallbacks(Events::EVENT_AFTER_UPDATE, $entity);
            }
            $this->persistHasManyChanges($entity);
            $entity->markAsUpdated();
        }
        $this->events->invokeCallbacks(Events::EVENT_AFTER_PERSIST, $entity);

        return isset($result) ? $result : null;
    }
311159
protected function isScheduled($objectHashId)
    {
        return isset($this->scheduledForInsertion[$objectHashId])
               || isset($this->scheduledForUpdate[$objectHashId])
               || isset($this->scheduledForDeletion[$objectHashId]);
    }
1235230
public function hasUnpersistedChanges()
    {
        $unitOfWork = $this->entityManager->getUnitOfWork();
        $unitOfWork->computeChangeSets();

        if ($unitOfWork->getScheduledEntityInsertions() !== []
            || $unitOfWork->getScheduledEntityUpdates() !== []
            || $unitOfWork->getScheduledEntityDeletions() !== []
            || $unitOfWork->getScheduledCollectionDeletions() !== []
            || $unitOfWork->getScheduledCollectionUpdates() !== []
        ) {
            return true;
        }

        return false;
    }
380542
protected function _isFileUploadPresent($entity) {
		$field = $this->getConfig('fileField');
		if ($this->getConfig('ignoreEmptyFile') === true) {
			if (!isset($entity[$field]['error']) || $entity[$field]['error'] === UPLOAD_ERR_NO_FILE) {
				return false;
			}
		}

		return true;
	}
700607
public function save($entity) {
        $this->load();
        $mapper = MapperBuilder::buildFromClassName($this->mapping, get_class($entity));
        if (is_null($entity->getId())) {
            $affectedRows = $this->insertEntity($entity, $mapper);
        } else {
            $affectedRows = $this->updateEntity($entity, $mapper);
        }
        if (0 < $affectedRows) {
            return true;
        } else {
            return false;
        }
    }
777144
public function scheduleForUpdate($entity) : void
    {
        $oid = spl_object_id($entity);

        if (! isset($this->entityIdentifiers[$oid])) {
            throw ORMInvalidArgumentException::entityHasNoIdentity($entity, 'scheduling for update');
        }

        if (isset($this->entityDeletions[$oid])) {
            throw ORMInvalidArgumentException::entityIsRemoved($entity, 'schedule for update');
        }

        if (! isset($this->entityUpdates[$oid]) && ! isset($this->entityInsertions[$oid])) {
            $this->entityUpdates[$oid] = $entity;
        }
    }
997337
public function isNested($entity)
    {
        if ($nestedDocument = $this->getClassAnnotation($entity, self::DOCUMENT_NESTED_CLASS)) {
            return true;
        }

        return false;
    }
1046357
public function deleted(Model $entity)
    {
        $data = [
            'database' => $this->getConnectionName(),
            'driver' => $this->getDriverName(),
        ];

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

        return true;
    }
891851
public function refresh ($entity)
    {
        // Return if not saved and not in database.
        if (! $entity->_saved) return false;
        $structure = $this->getEntityStructure($entity);

        // ID Data.
        $idColumn = $structure->primaryColumn->name;
        $idValue = $entity->_id;

        if ($structure->primaryColumn->type === 'integer')
            $idValue = intval($idValue);

        // Clear Relationship Cache.
        $entity::clearCache();

        // Query for refreshing.
        $query = new Query($entity);
        $newEntity = $query->select()
            ->where($idColumn, $idValue)
            ->one();

        // If no entity is found (when refreshing).
        if (! $newEntity) return false;

        // Map to the old instance
        foreach ($structure->columns as $column) {
            $entity->{$column->propertyName} = $newEntity->{$column->propertyName};
        }

        return true;
    }
478894
protected function deleteEntity($entity)
    {
        $this->checkEntityType($entity);

        $delete = new Delete($this->aggregate($entity), $this->newQueryBuilder());

        $delete->execute();
    }
740488
public function scheduleForInsert($xmlEntity)
    {
        $oid = spl_object_hash($xmlEntity);

        if (isset($this->entityUpdates[$oid])) {
            throw new \InvalidArgumentException("Dirty xml entity can not be scheduled for insertion.");
        }
        if (isset($this->entityDeletions[$oid])) {
            throw new \InvalidArgumentException("Removed xml entity can not be scheduled for insertion.");
        }
        if (isset($this->entityInsertions[$oid])) {
            throw new \InvalidArgumentException("Xml entity can not be scheduled for insertion twice.");
        }

        $this->entityInsertions[$oid] = $xmlEntity;

        if (isset($this->entityIdentifiers[$oid])) {
            $this->addToIdentityMap($xmlEntity);
        }
    }
316265
public function delete($entity)
    {
        $query = $this->db->table($entity->definition()->getName());
        $primary = $entity->id();
        if (isset($this->objects[$entity->definition()->getName()][base64_encode(serialize($primary))])) {
            foreach ($primary as $k => $v) {
                $query->filter($k, $v);
            }
            $query->delete();
            unset($this->objects[$entity->definition()->getName()][base64_encode(serialize($primary))]);
        }
    }
1289398
public function isScheduledForDirtyCheck($entity)
    {
        $rootEntityName = $this->em->getClassMetadata(get_class($entity))->rootEntityName;

        return isset($this->scheduledForSynchronization[$rootEntityName][spl_object_hash($entity)]);
    }