src/Model.php
public function save()
    {
        if ($this instanceof Immutable) {
            throw new Exception\Immutable($this);
        }
        $errors = [];
        if (method_exists($this, 'notify')) {
            $notify = clone $this;
        }
        foreach ($this->__adapters as $model) {
            if ($model->isDirty()) {
                if ($model->isNew() && $this instanceof Uncreateable) {
                    throw new Exception\Uncreateable($this);
                }
                if (!$model->save()) {
                    $errors[] = true;
                }
            }
        }
        $annotations = $this->annotations()['properties'];
        foreach ($annotations as $prop => $anns) {
            if (isset($anns['Private']) || $prop{0} == '_') {
                continue;
            }
            $value = $this->$prop;
            if (is_object($value)) {
                if ($value instanceof Collection && $value->isDirty()) {
                    if ($error = $value->save()) {
                        $errors = array_merge($errors, $error);
                    }
                } elseif ($save = Helper::modelSaveMethod($value)
                    and !method_exists($value, 'isDirty') || $value->isDirty()
                ) {
                    if (!$value->$save()) {
                        $errors[] = true;
                    }
                }
            }
        }
        if (isset($notify)) {
            $notify->notify();
        }
        $this->markClean();
        return $errors ? $errors : null;
    }
public function save()
    {
        if ($this instanceof Immutable) {
            throw new Exception\Immutable($this);
        }
        $errors = [];
        if (method_exists($this, 'notify')) {
            $notify = clone $this;
        }
        foreach ($this->__adapters as $model) {
            if ($model->isDirty()) {
                if ($model->isNew() && $this instanceof Uncreateable) {
                    throw new Exception\Uncreateable($this);
                }
                if (!$model->save()) {
                    $errors[] = true;
                }
            }
        }
        $annotations = $this->annotations()['properties'];
        foreach ($annotations as $prop => $anns) {
            if (isset($anns['Private']) || $prop{0} == '_') {
                continue;
            }
            $value = $this->$prop;
            if (is_object($value)) {
                if ($value instanceof Collection && $value->isDirty()) {
                    if ($error = $value->save()) {
                        $errors = array_merge($errors, $error);
                    }
                } elseif ($save = Helper::modelSaveMethod($value)
                    and !method_exists($value, 'isDirty') || $value->isDirty()
                ) {
                    if (!$value->$save()) {
                        $errors[] = true;
                    }
                }
            }
        }
        if (isset($notify)) {
            $notify->notify();
        }
        $this->markClean();
        return $errors ? $errors : null;
    }
public function save ( ) { if ( $ this instanceof Immutable ) { throw new Exception \ Immutable ( $ this ) ; } $ errors = [ ] ; if ( method_exists ( $ this , 'notify' ) ) { $ notify = clone $ this ; } foreach ( $ this -> __adapters as $ model ) { if ( $ model -> isDirty ( ) ) { if ( $ model -> isNew ( ) && $ this instanceof Uncreateable ) { throw new Exception \ Uncreateable ( $ this ) ; } if ( ! $ model -> save ( ) ) { $ errors [ ] = true ; } } } $ annotations = $ this -> annotations ( ) [ 'properties' ] ; foreach ( $ annotations as $ prop => $ anns ) { if ( isset ( $ anns [ 'Private' ] ) || $ prop { 0 } == '_' ) { continue ; } $ value = $ this -> $ prop ; if ( is_object ( $ value ) ) { if ( $ value instanceof Collection && $ value -> isDirty ( ) ) { if ( $ error = $ value -> save ( ) ) { $ errors = array_merge ( $ errors , $ error ) ; } } elseif ( $ save = Helper :: modelSaveMethod ( $ value ) and ! method_exists ( $ value , 'isDirty' ) || $ value -> isDirty ( ) ) { if ( ! $ value -> $ save ( ) ) { $ errors [ ] = true ; } } } } if ( isset ( $ notify ) ) { $ notify -> notify ( ) ; } $ this -> markClean ( ) ; return $ errors ? $ errors : null ; }
Persists the model back to storage based on the specified adapters.
If an adapter supports transactions, you are encouraged to use them;
but you should do so in your own code.

@return null|array null on success, or an array of errors encountered.
@throws Ornament\Exception\Immutable if the model implements the
Immutable interface and is thus immutable.
@throws Ornament\Exception\Uncreateable if the model is new and implemnts
the Uncreatable interface and can therefor not be created
programmatically.
Persists the model back to storage based on the specified adapters . If an adapter supports transactions you are encouraged to use them ; but you should do so in your own code .