Save an Entity in the cache.

@param EntityDocument $entity
4553
public function save( EntityDocument $entity ) {
		if( !$this->cache->save(
			$this->getCacheIdFromEntityId( $entity->getId() ),
			$entity,
			$this->lifeTime
		) ) {
			throw new RuntimeException( 'The cache failed to save for entity ' . $entity->getId()->getSerialization() );
		}
	}
1312742
protected function updateField(Entity $entity, $field) {
		if ($entity->dirty($field)) {
			return;
		}

		$entity->set($field, $this->getUserId());
	}
1101753
public function commit($entity = null)
    {
        if ($this->evm->hasListeners(Events::preFlush)) {
            $this->evm->dispatchEvent(Events::preFlush, new Event\PreFlushEventArgs($this->sm));
        }

        //TODO: single/array entity commit handling
        $this->commitRemoved();
        $this->commitPersisted();

        //Force refresh of updated indexes
        if ($entity === true) {
            $client = $this->sm->getClient();
            foreach (array_unique($this->updatedIndexes) as $index) {
                $client->refreshIndex($index);
            }
        }

        $this->clear();

        if ($this->evm->hasListeners(Events::postFlush)) {
            $this->evm->dispatchEvent(Events::postFlush, new Event\PostFlushEventArgs($this->sm));
        }
    }
728679
public function save(Entity $entity)
    {
        $postData = $this->hydrator->extract($entity);
                    
        if ($entity->getHistoryId()) {
            $this->update = new Update('history'); 
                
            $this->update->set($postData);  
                
            $this->update->where(array(
                'history.history_id = ?' => $entity->getHistoryId()
            ));
                    
            $this->updateRow();            
        } else {
            $this->insert = new Insert('history'); 
                
            $this->insert->values($postData);
                
            $id = $this->createRow();
                
            $entity->setHistoryId($id);        
        }
                    
        return $this->get($entity->getHistoryId());
    }
721458
public function insert($entity)
    {
        $persistor = new DoctrinePersistor(
            $this->connection,
            $this->table,
            $this->entityRegistry->getEntityBuilder(),
            $this->entityRegistry
        );
        $persistor->insert($entity);
    }
272220
protected function persist($entity)
    {
        $manager = $this->getDoctrine()->getManager();
        $manager->persist($entity);
        $manager->flush();
    }
1323068
public function beforeSave(Event $event, Entity $entity) {
		if (isset($entity['name'])) {
			$entity['name'] = mb_strtolower($entity['name']);
		}
		if (isset($entity['ext'])) {
			$entity['ext'] = mb_strtolower($entity['ext']);
		}

		return true;
	}
687047
public function persist($entity)
    {
        if (!$this->isRepositoryWritable()) {
            throw $this->createNotWritableException();
        }

        return $this->trigger(__FUNCTION__, [
            'entity' => $entity,
        ]);
    }
1070600
protected function update($entity)
    {
        // If this entity was a child of aggregate roots, then call its methods to set the aggregate root Id
        $this->entityRegistry->runAggregateRootCallbacks($entity);
        $dataMapper = $this->getDataMapper($this->entityRegistry->getClassName($entity));
        $dataMapper->update($entity);
        $this->entityRegistry->registerEntity($entity);
    }
594296
public function afterSave(Event $event, EntityInterface $entity) {
		if ($this->_checkEvent($event) && $entity->isNew()) {
			$fileField = $this->getConfig('fileField');

			$hash = StorageUtils::getFileHash($entity->get($fileField)['tmp_name']);
			$path = $this->pathBuilder()->fullPath($entity);

			$entity->set('hash', $hash);
			$entity->set('path', $path);

			if (!$this->_storeFile($event)) {
				return;
			}

			$event->result = true;
			$event->stopPropagation();
		}
	}
590379
public function afterSave(Event $event, EntityInterface $entity)
    {
        $property = $this->versionAssociation()->getProperty();
        $entity->unsetProperty($property);
    }
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;
        }
    }
703503
public function update($entity)
    {
        $eloquentModel = $this->getEloquentModel($entity, true);

        $this->updateRelations($eloquentModel, 'update');

        $eloquentModel->save();

        $eloquentModel->afterSaving($entity, 'update');
    }
879340
public function stashEntity($entity)
    {
        $className = $this->getClassName($entity);
        $entityId  = $this->getEntityId($entity);

        if (!isset($this->stashedEntities[$className])) {
            $this->stashedEntities[$className] = [];
        }

        $this->stashedEntities[$className][$entityId] = $entity;
    }
282742
public function insert($entity)
    {
        $eloquentModel = $this->getEloquentModel($entity);

        $this->updateRelations($eloquentModel, 'insert');

        $eloquentModel->save();

        $eloquentModel->afterSaving($entity, 'insert');
    }
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;
    }
1079715
public function beforeSave(Event $event, Entity $entity) {
		if (isset($entity['name'])) {
			$entity['name'] = ucwords($entity['name']);
		}

		return true;
	}