Cake\ORM\Table::_onSaveSuccess PHP Method

_onSaveSuccess() protected method

Handles the saving of children associations and executing the afterSave logic once the entity for this table has been saved successfully.
protected _onSaveSuccess ( Cake\Datasource\EntityInterface $entity, ArrayObject $options ) : boolean
$entity Cake\Datasource\EntityInterface the entity to be saved
$options ArrayObject the options to use for the save operation
return boolean True on success
    protected function _onSaveSuccess($entity, $options)
    {
        $success = $this->_associations->saveChildren($this, $entity, $options['associated'], ['_primary' => false] + $options->getArrayCopy());
        if (!$success && $options['atomic']) {
            return false;
        }
        $this->dispatchEvent('Model.afterSave', compact('entity', 'options'));
        if ($options['atomic'] && !$this->connection()->inTransaction()) {
            throw new RolledbackTransactionException(['table' => get_class($this)]);
        }
        if (!$options['atomic'] && !$options['_primary']) {
            $entity->clean();
            $entity->isNew(false);
            $entity->source($this->registryAlias());
        }
        return true;
    }