src/domain/base/ObjectDomainTrait.php
public function update($id, $data) {
		// find
		$model = $this->get($id);

		if ($model === null) {
			return new NotFound(['message' => 'Object not found.']);
		}

		// hydrate
		$serializer = Object::getSerializer();
		$model = $serializer->hydrate($model, $data);
		$this->hydrateRelationships($model, $data);

		// dispatch pre save hooks
		$this->dispatch(ObjectEvent::PRE_UPDATE, $model, $data);
		$this->dispatch(ObjectEvent::PRE_SAVE, $model, $data);

		// validate
		$validator = $this->getValidator();
		if ($validator !== null && !$validator->validate($model)) {
			return new NotValid([
				'errors' => $validator->getValidationFailures()
			]);
		}

		// save and dispath post save hooks
		$rows = $model->save();
		$this->dispatch(ObjectEvent::POST_UPDATE, $model, $data);
		$this->dispatch(ObjectEvent::POST_SAVE, $model, $data);

		$payload = ['model' => $model];

		if ($rows === 0) {
			return new NotUpdated($payload);
		}

		return new Updated($payload);
	}
public function update($id, $data) {
		// find
		$model = $this->get($id);

		if ($model === null) {
			return new NotFound(['message' => 'Object not found.']);
		}

		// hydrate
		$serializer = Object::getSerializer();
		$model = $serializer->hydrate($model, $data);
		$this->hydrateRelationships($model, $data);

		// dispatch pre save hooks
		$this->dispatch(ObjectEvent::PRE_UPDATE, $model, $data);
		$this->dispatch(ObjectEvent::PRE_SAVE, $model, $data);

		// validate
		$validator = $this->getValidator();
		if ($validator !== null && !$validator->validate($model)) {
			return new NotValid([
				'errors' => $validator->getValidationFailures()
			]);
		}

		// save and dispath post save hooks
		$rows = $model->save();
		$this->dispatch(ObjectEvent::POST_UPDATE, $model, $data);
		$this->dispatch(ObjectEvent::POST_SAVE, $model, $data);

		$payload = ['model' => $model];

		if ($rows === 0) {
			return new NotUpdated($payload);
		}

		return new Updated($payload);
	}
public function update ( $ id , $ data ) { // find $ model = $ this -> get ( $ id ) ; if ( $ model === null ) { return new NotFound ( [ 'message' => 'Object not found.' ] ) ; } // hydrate $ serializer = Object :: getSerializer ( ) ; $ model = $ serializer -> hydrate ( $ model , $ data ) ; $ this -> hydrateRelationships ( $ model , $ data ) ; // dispatch pre save hooks $ this -> dispatch ( ObjectEvent :: PRE_UPDATE , $ model , $ data ) ; $ this -> dispatch ( ObjectEvent :: PRE_SAVE , $ model , $ data ) ; // validate $ validator = $ this -> getValidator ( ) ; if ( $ validator !== null && ! $ validator -> validate ( $ model ) ) { return new NotValid ( [ 'errors' => $ validator -> getValidationFailures ( ) ] ) ; } // save and dispath post save hooks $ rows = $ model -> save ( ) ; $ this -> dispatch ( ObjectEvent :: POST_UPDATE , $ model , $ data ) ; $ this -> dispatch ( ObjectEvent :: POST_SAVE , $ model , $ data ) ; $ payload = [ 'model' => $ model ] ; if ( $ rows === 0 ) { return new NotUpdated ( $ payload ) ; } return new Updated ( $ payload ) ; }
Updates a Object with the given idand the provided data

@param mixed $id
@param mixed $data
@return PayloadInterface
Updates a Object with the given idand the provided data