main/app/API/Crud.php
public function update($class, $data, array $options = [])
    {
        // validates submitted data.
        if (!in_array(self::NO_VALIDATE, $options)) {
            $errors = $this->validate($class, $data, ValidatorProvider::UPDATE);

            if (count($errors) > 0) {
                return $errors;
            }
        }

        $oldObject = $this->om->getObject($data, $class) ?? new $class();
        $this->checkPermission('EDIT', $oldObject, [], true);
        $oldData = $this->serializer->serialize($oldObject);

        if (!$oldData) {
            $oldData = [];
        }

        $object = $this->serializer->deserialize($data, $oldObject, $options);

        if ($this->dispatch('update', 'pre', [$object, $options, $oldData])) {
            $this->om->save($object);
            $this->dispatch('update', 'post', [$object, $options, $oldData]);
        }

        return $object;
    }
public function update($class, $data, array $options = [])
    {
        // validates submitted data.
        if (!in_array(self::NO_VALIDATE, $options)) {
            $errors = $this->validate($class, $data, ValidatorProvider::UPDATE);

            if (count($errors) > 0) {
                return $errors;
            }
        }

        $oldObject = $this->om->getObject($data, $class) ?? new $class();
        $this->checkPermission('EDIT', $oldObject, [], true);
        $oldData = $this->serializer->serialize($oldObject);

        if (!$oldData) {
            $oldData = [];
        }

        $object = $this->serializer->deserialize($data, $oldObject, $options);

        if ($this->dispatch('update', 'pre', [$object, $options, $oldData])) {
            $this->om->save($object);
            $this->dispatch('update', 'post', [$object, $options, $oldData]);
        }

        return $object;
    }
public function update ( $ class , $ data , array $ options = [ ] ) { // validates submitted data. if ( ! in_array ( self :: NO_VALIDATE , $ options ) ) { $ errors = $ this -> validate ( $ class , $ data , ValidatorProvider :: UPDATE ) ; if ( count ( $ errors ) > 0 ) { return $ errors ; } } $ oldObject = $ this -> om -> getObject ( $ data , $ class ) ?? new $ class ( ) ; $ this -> checkPermission ( 'EDIT' , $ oldObject , [ ] , true ) ; $ oldData = $ this -> serializer -> serialize ( $ oldObject ) ; if ( ! $ oldData ) { $ oldData = [ ] ; } $ object = $ this -> serializer -> deserialize ( $ data , $ oldObject , $ options ) ; if ( $ this -> dispatch ( 'update' , 'pre' , [ $ object , $ options , $ oldData ] ) ) { $ this -> om -> save ( $ object ) ; $ this -> dispatch ( 'update' , 'post' , [ $ object , $ options , $ oldData ] ) ; } return $ object ; }
Updates an entry of `class` with `data`.

@param string $class   - the class of the entity to updates
@param mixed  $data    - the serialized data of the object to create
@param array  $options - additional update options

@return object
Updates an entry of class with data .