Update an Entity by based on entity type.

@param  array  $data
@param  mixed  $entity
@return Payload
492065
protected function updateByType($data, $entity)
	{
		// Note: this switch exists like this because PHP does not have "traditional method overloading".
		switch(gettype($entity))
		{
			// UUID string
			case 'string':
				$entityPayload = $this->getOneByUuid($entity);

				if($entityPayload->getStatus() != 'found')
				{
					return $entityPayload;
				}

				// Update the Entity itself.
				return $this->updateByEntity($data, $entityPayload->getData()->first());
			break;

			// Use an Object to update.
			case 'object':
				switch($entity->getType(true))
				{
					// Use an EntityIdentifier to update.
					case IdentifierServiceProvider::getProviderKey():

						// Update the Entity itself.
						return $this->updateByIdentifier($entity, $data);
					break;

					// Use an Entity to update.
					default:
						// Make sure this service is configured to use the given entity's aggregate.
						if(array_key_exists($entity->getType(true), $this->getAggregate()))
						{
							// Update the Entity itself.
							return $this->updateByEntity($data, $entity);
						}
						else
						{
							return new Payload(null, $entity->getType() . '_' . 'not_configured');
						}
				}
			break;

			// Use a compound key to update.
			case 'array':
				$entityPayload = $this->getOneByCompoundKey($entity);

				if($entityPayload->getStatus() != 'found')
				{
					return $entityPayload;
				}

				// Update the Entity itself.
				return $this->updateByEntity($data, $entityPayload->getData());
			break;

			default:
				return new Payload(null, 'invalid_entity');
		}
	}
868111
private function update($object, array $data)
    {
        //only save when a change is detected
        if (!empty($data)) {
            $queryBuilder = $this->manager->getDriver()->getQueryBuilder();
            $primaryKey   = $this->getPrimaryKey();

            $this->manager->postPendingQuery(
                new PendingQuery(
                    $this,
                    PendingQuery::TYPE_UPDATE,
                    $queryBuilder
                        ->update($this->getTable())
                        ->values($queryBuilder->createPositionalParameter($data))
                        ->where(
                            $queryBuilder->expression()->eq(
                                $primaryKey,
                                $queryBuilder->createPositionalParameter(
                                    $this->getState($object)->getOriginalFieldData($primaryKey)
                                )
                            )
                        )
                )
            );
        }

        return $this->getPrimaryKeyValue($object);
    }
971737
public static function create($data = [], Entity $entity = null)
    {
        $record = new static($data, $entity);

        $record->save();

        return $record;
    }
1336543
public function commit($entity)
    {
        switch ($entity->getEntityState()) {
            case AnDomain::STATE_NEW:
                $operation = AnDomain::OPERATION_INSERT;
                $command = 'insert';
                break;
            case AnDomain::STATE_MODIFIED :
                //get all the updated serializable property/value pairs
                $operation = AnDomain::OPERATION_UPDATE;
                $command = 'update';
                break;
            case  AnDomain::STATE_DELETED :
                $operation = AnDomain::OPERATION_DELETE;
                $command = 'delete';
                break;
            default :
                return;
        }

        $context = $this->getCommandContext();
        $context->operation = $operation;
        $context->entity = $entity;
        $context->data = array();
        $store = $this->getStore();

        if ($context->result = $this->getCommandChain()->run('before.'.$command, $context) !== false) {
            $context->data = $entity->getAffectedRowData();

            switch ($operation) {
                case(AnDomain::OPERATION_INSERT) :
                    if (!count($context->data)) {
                        throw new AnDomainRepositoryException('Attempting to store an entity with empty data');
                    }

                    $context->result = $store->insert($this, $context->data);
                    break;

                case(AnDomain::OPERATION_UPDATE) :
                case(AnDomain::OPERATION_DELETE) :

                    $keys = $this->_description->getIdentityProperty()->serialize($entity->getIdentityId());
                    $keys = array($this->_description->getIdentityProperty()->getName() => $entity->getIdentityId());

                    if ($operation & AnDomain::OPERATION_UPDATE) {
                        $context->result = count($context->data) ? $this->update($context->data, $keys) : true;
                    } else {
                        $context->result = $this->destroy($keys);
                    }
            }

            $this->getCommandChain()->run('after.'.$command, $context);
        }

        return    $context->result !== false;
    }
760894
protected function updateBankAccount(BankAccount $entity, $data)
    {
        $success = true;

        if (isset($data['bic'])) {
            $entity->setBic($data['bic']);
        }
        $entity->setIban($data['iban']);
        $entity->setPublic($this->getBooleanValue((array_key_exists('public', $data) ? $data['public'] : false)));
        if (isset($data['bankName'])) {
            $entity->setBankName($data['bankName']);
        }

        return $success;
    }
162767
public function generateEntity($entity, array $data)
    {
        $handlers = $this->getHandlers();

        if (isset($handlers[$entity]['mapping']) && isset($handlers[$entity]['pattern'])) {
            $data += array('placeholders' => $handlers[$entity]['mapping']);
            return $this->generate($handlers[$entity]['pattern'], $data);
        }

        return null;
    }
585687
public function update(AbstractEntity $entity)
    {
        if ($this->updatedTimestampColumn) {
            $entity->exchangeArray([$this->updatedTimestampColumn => time()]);
        }

        if ($this->updatedDatetimeColumn) {
            $entity->exchangeArray([$this->updatedDatetimeColumn => date('Y-m-d H:i:s')]);
        }

        $this->updateRow($entity);

        return $entity;
    }
906817
public function update(array $data)
    {
        $this->manager->postPendingQuery(
            new PendingQuery(
                $this->entity,
                PendingQuery::TYPE_UPDATE,
                $this->getUpdateQuery($data),
                $this->parameters
            )
        );
    }
300542
public function updateByPrimaryKey($key, array $data)
    {
        $this->updateByField($this->entity->getPrimaryKey(), $key, $data);
    }
821863
public function update(array $entityData)
    {
        $this->preUpdate($entityData);
        $entity = $this->doUpdate($entityData);
        $this->postUpdate($entityData);
        $this->getEntityManager()->flush($entity);

        return $entity;
    }
654594
public function update($api, $id, array $data = [])
    {
        return $this->checkException($this->callHttpMethod($this->normalizeUri($api, $id), Request::METHOD_PUT, $data));
    }
1371171
private function updateActiveRow(Entity $entity) {
		$reflection = $entity->getColumns();
		$record = array();
		foreach ($reflection as $property) {
			$name = $property['name'];
			if ($entity->toRow()->$name != $entity->$name) {
				$record[$name] = $entity->$name;
			}
		}
		if (count($record) > 0) {
			$entity->toRow()->update($record);
		}
		$this->addLoop($entity);
	}
1245510
public function update($data, $object)
	{
		$updated = $object->update($data);

		// @todo: Double Check that we should be returning updated not object
		if( ! $updated)
		{
			return new Payload($object , 'not_updated');
		}

		return new Payload($object, 'updated');
	}
539381
public final function entity(array $data = []): Entity
    {
        $entity = new Entity($this, $data);
        if (method_exists($this, 'onEntity')) {
            $this->onEntity($entity);
        }

        return $entity;
    }
498102
final public function ormToEntity($data = [], $entity = '') {
        $entities = [];

        foreach ($data as $value) {
            if ($entity != '') {
                $entityName = '\entity\\' . $entity;
                $entityObject = new $entityName(Database::instance()->db());

                foreach ($value as $key => $value2) {
                    $entityObject->$key = $value2;
                }
            }
            else {
                $entityObject = new Multiple($data);
            }

            array_push($entities, $entityObject);
        }

        return $entities;
    }
945093
public function update(array $data, $where)
    {
        $tableSpec = ($this->_schema ? $this->_schema . '.' : '') . $this->_name;
        return $this->_db->update($tableSpec, $data, $where);
    }
227306
protected static function exeCreate(string $entity, array $data, bool $save)
    {
        $dicionario = new Dicionario($entity);
        $dicionario->setData($data);

        if ($save)
            $dicionario->save();

        return self::return($dicionario);
    }