src/Modelling/ModelState.php
final protected function setModelValue($propertyName, $value)
    {
        try {
            $oldValue = (isset($this->modelData[$propertyName])) ? $this->modelData[$propertyName]: null;
        } catch (\Exception $ex) {
            // Catch any exceptions thrown when trying to retrieve the old value for the sake
            // of comparison to trigger the property changed handlers.
            $oldValue = null;
        }

        $this->modelData[$propertyName] = $value;

        if ($value instanceof ModelState) {
            $this->attachChangeListenerToModelProperty($propertyName, $value);
        }

        if ($oldValue != $value) {
            if (!$this->propertyChangeEventsDisabled) {
                // Don't fire changes if they are disabled.
                $this->raisePropertyChangedCallbacks($propertyName, $value, $oldValue);
                $this->traitRaiseEvent("AfterChange", $this);
            }
        }
    }
final protected function setModelValue($propertyName, $value)
    {
        try {
            $oldValue = (isset($this->modelData[$propertyName])) ? $this->modelData[$propertyName]: null;
        } catch (\Exception $ex) {
            // Catch any exceptions thrown when trying to retrieve the old value for the sake
            // of comparison to trigger the property changed handlers.
            $oldValue = null;
        }

        $this->modelData[$propertyName] = $value;

        if ($value instanceof ModelState) {
            $this->attachChangeListenerToModelProperty($propertyName, $value);
        }

        if ($oldValue != $value) {
            if (!$this->propertyChangeEventsDisabled) {
                // Don't fire changes if they are disabled.
                $this->raisePropertyChangedCallbacks($propertyName, $value, $oldValue);
                $this->traitRaiseEvent("AfterChange", $this);
            }
        }
    }
final protected function setModelValue ( $ propertyName , $ value ) { try { $ oldValue = ( isset ( $ this -> modelData [ $ propertyName ] ) ) ? $ this -> modelData [ $ propertyName ] : null ; } catch ( \ Exception $ ex ) { // Catch any exceptions thrown when trying to retrieve the old value for the sake // of comparison to trigger the property changed handlers. $ oldValue = null ; } $ this -> modelData [ $ propertyName ] = $ value ; if ( $ value instanceof ModelState ) { $ this -> attachChangeListenerToModelProperty ( $ propertyName , $ value ) ; } if ( $ oldValue != $ value ) { if ( ! $ this -> propertyChangeEventsDisabled ) { // Don't fire changes if they are disabled. $ this -> raisePropertyChangedCallbacks ( $ propertyName , $ value , $ oldValue ) ; $ this -> traitRaiseEvent ( "AfterChange" , $ this ) ; } } }
Sets a models property value while also raising property changed notifications if appropriate.

This should be used from setters instead of changing $this->modelData directly.

@param $propertyName
@param $value
Sets a models property value while also raising property changed notifications if appropriate .