INTERNAL:
Registers an entity as managed.

@param object  $entity The entity.
@param mixed[] $id     Map containing identifier field names as key and its associated values.
@param mixed[] $data   The original entity data.
18860
public function registerManaged($entity, array $id, array $data)
    {
        $isProxy = $entity instanceof GhostObjectInterface && ! $entity->isProxyInitialized();
        $oid     = spl_object_id($entity);

        $this->entityIdentifiers[$oid]  = $id;
        $this->entityStates[$oid]       = self::STATE_MANAGED;
        $this->originalEntityData[$oid] = $data;

        $this->addToIdentityMap($entity);

        if ($entity instanceof NotifyPropertyChanged && ! $isProxy) {
            $entity->addPropertyChangedListener($this);
        }
    }
314425
public function delete($id)
    {
        $entity = $this->get($id);

        $this->manager->remove($entity);
        $this->manager->flush();
    }
502460
function save( $id, $data )
    {
        $data['__meta']['sid'] = $this->sid;

        $params = [
            'index' => $this->config->index,
            'type' => $this->config->type,
            'id' => $id,
            'body' => $data,
        ];

        $this->client->index($params);
    }
62219
public function write($id, $data)
    {
        $session = $this->entityManager->find($this->entityManager, $id);
        if (null === $session) {
            $session = new $this->entityName();
            $session->{$this->primaryKeyColumn} = $id;
        }

        $session->{$this->dataColumn} = $data;
        $session->{$this->lifetimeColumn} = $this->lifetime;
        $session->{$this->modifiedColumn} = time();
        $this->entityManager->persist($session);

        try {
            $this->entityManager->flush();
            return true;
        } catch (\Doctrine\ORM\OptimisticLockException $exc) {
            return false;
        }
    }
796729
public function deleteObject($entity, $_id)
	{
		$retValue = true;
		$arrayWhere = array('_id' => $_id);

		if (! is_null($this->_conn)){
			$this->_conn->delete($entity, $arrayWhere);

			if ($this->error($this->_conn->error()))
				$retValue = false;
		}
		
		return $retValue;
	}
1185502
public function update($id, array $data)
    {
        $this->validateId($id);

        $entity = $this->getById($id);
        $form   = $this->getEditForm();

        $form->bind($entity);
        $form->setData($data);

        if (!$valid = $form->isValid()) {
            return false;
        }

        $this->updateFromNode($entity);

        $this->getMapper()->save($entity);

        return $entity;
    }
717560
protected void store(Object id, Object entity)
    {
        store(id, entity, Boolean.TRUE);
    }
1312928
protected function enrichEntityWithMetaData($id, Entity $entity)
    {
        $entity->set('id', $id);
        $createdEntity = $this->get($entity->get('id'));
        $entity->set('version', $createdEntity->get('version'));
        $entity->set('created_at', $createdEntity->get('created_at'));
        $entity->set('updated_at', $createdEntity->get('updated_at'));
    }
1105596
public function put($id = null, $data = array())
    {

        $args = func_get_args();
        if(count($args) == 2){
            $args = $id;
        }else{
            $data = array_pop($args);
        }

        try {
            $this->client->request($this, 'put', $args, $data);
        } catch(Exception $ex) {
            $this->dispatchException($ex);
        }

        return true;
    }
1254904
private function initializeEntity($id, $created)
    {
        $this->id = $id ?: $this->generateEntityID();
        $this->created = $created ?: $this->generateCreatedTime();
    }
106110
public function trigger($event, $data, $id = null)
    {
        if (!isset($id)) {
            $id = $this->lastId++;
        }
        $this->putLine('event: ' . $event);
        $this->putLine('id: ' . $id);
        $this->putLine('data: ' . $data);
        $this->putLine();
        $this->flush();
    }
254688
public function write($id, $data)
    {
        $session = \Doctrine::getTable($this->_tableName)->find($id);
        if (false === $session) {
            $session = new $this->_tableName();
            $session->{$this->_primaryKeyColumn} = $id;
        }

        $session->{$this->_dataColumn} = $data;
        $session->{$this->_lifetimeColumn} = $this->_lifetime;
        $session->{$this->_modifiedColumn} = time();

        if ($session->save()) {
            return true;
        }

        return false;
    }
925840
public function add($entity)
    {
        $idAccessorRegistry = $this->unitOfWork->getEntityRegistry()->getIdAccessorRegistry();
        $entityId           = $idAccessorRegistry->getEntityId($entity);

        $mapClass = $this->mapRepository->getEntityClass();

        if (empty($entityId)) {
            $this->entityRepository->add($entity);
            $map         = new $mapClass;
            $varJoinName = $this->relation->varJoinName();
            $this->mapRepository->add($map);
            $this->unitOfWork->getEntityRegistry()->registerAggregateRootCallback(
                $entity,
                $map,
                function ($root, $child) use ($varJoinName, $idAccessorRegistry) {
                    $entityId              = $idAccessorRegistry->getEntityId($root);
                    $child->{$varJoinName} = $entityId;
                    $this->map[]           = $entityId;
                }
            )
            ;

            return;
        }

        if (in_array($entityId, $this->map)) {
            throw new OrmException("Entity with id $entityId already exists");
        }

        $map                 = new $mapClass;
        $varJoinName         = $this->relation->varJoinName();
        $map->{$varJoinName} = $entityId;
        $this->mapRepository->add($map);
        $this->map[] = $entityId;
    }
48302
public function registerReconstitutedEntity($entity, array $entityData)
    {
        $this->reconstitutedEntities->attach($entity);
        $this->reconstitutedEntitiesData[$entityData['identifier']] = $entityData;
    }
558906
private function insert($id, $data)
    {
        $platform = $this->persistence->getPlatform();
        $columns = array_merge(array(
            self::DIAGNOSTIC_ID => $id,
            self::DIAGNOSTIC_CREATED_AT => $platform->getNowExpression()
        ), $data);

        $query = 'INSERT INTO ' . self::DIAGNOSTIC_TABLE . '(' . implode(', ', array_map('Doctrine\Common\Inflector\Inflector::tableize',array_keys($columns))) . ')' .
                 ' VALUES (' . str_repeat("?,", count($columns) - 1) . '? )';

        return $this->persistence->exec($query, array_values($columns));
    }
1262171
private function addToDecodedRegistry($entity, EntityManager $em) {
        $className = get_class($entity);
        $metadata = $em->getClassMetadata($className);
        $getter = 'get' . self::capitalize($metadata->getIdentifier());
        $this->decodedRegistry[$className][$entity->$getter()] = true;
    }
50934
public function createEntity($entity, TableNode $fields) {
    $this->models->get($entity)->store($fields->getRowsHash());
  }