public function cascadingRestoreTrash(EntityInterface $entity = null, array $options = [])
    {
        $result = $this->restoreTrash($entity, $options);

        foreach ($this->_table->associations() as $association) {
            if ($this->_isRecursable($association, $this->_table)) {
                if ($entity === null) {
                    $result += $association->getTarget()->cascadingRestoreTrash(null, $options);
                } else {
                    $foreignKey = (array)$association->getForeignKey();
                    $bindingKey = (array)$association->getBindingKey();
                    $conditions = array_combine($foreignKey, $entity->extract($bindingKey));

                    foreach ($association->find('withTrashed')->where($conditions) as $related) {
                        if (!$association->getTarget()->cascadingRestoreTrash($related, ['_primary' => false] + $options)) {
                            $result = false;
                        }
                    }
                }
            }
        }

        return $result;
    }
public function cascadingRestoreTrash(EntityInterface $entity = null, array $options = [])
    {
        $result = $this->restoreTrash($entity, $options);

        foreach ($this->_table->associations() as $association) {
            if ($this->_isRecursable($association, $this->_table)) {
                if ($entity === null) {
                    $result += $association->getTarget()->cascadingRestoreTrash(null, $options);
                } else {
                    $foreignKey = (array)$association->getForeignKey();
                    $bindingKey = (array)$association->getBindingKey();
                    $conditions = array_combine($foreignKey, $entity->extract($bindingKey));

                    foreach ($association->find('withTrashed')->where($conditions) as $related) {
                        if (!$association->getTarget()->cascadingRestoreTrash($related, ['_primary' => false] + $options)) {
                            $result = false;
                        }
                    }
                }
            }
        }

        return $result;
    }
public function cascadingRestoreTrash ( EntityInterface $ entity = null , array $ options = [ ] ) { $ result = $ this -> restoreTrash ( $ entity , $ options ) ; foreach ( $ this -> _table -> associations ( ) as $ association ) { if ( $ this -> _isRecursable ( $ association , $ this -> _table ) ) { if ( $ entity === null ) { $ result += $ association -> getTarget ( ) -> cascadingRestoreTrash ( null , $ options ) ; } else { $ foreignKey = ( array ) $ association -> getForeignKey ( ) ; $ bindingKey = ( array ) $ association -> getBindingKey ( ) ; $ conditions = array_combine ( $ foreignKey , $ entity -> extract ( $ bindingKey ) ) ; foreach ( $ association -> find ( 'withTrashed' ) -> where ( $ conditions ) as $ related ) { if ( ! $ association -> getTarget ( ) -> cascadingRestoreTrash ( $ related , [ '_primary' => false ] + $ options ) ) { $ result = false ; } } } } } return $ result ; }
Restore an item from trashed status and all its related data

@param \Cake\Datasource\EntityInterface $entity Entity instance
@param array $options Restore operation options (only applies when restoring a specific entity).
@return bool|\Cake\Datasource\EntityInterface|int
Restore an item from trashed status and all its related data