@param string[] $cascade one of "persist", "remove", "merge", "detach", "refresh" or "ALL"

@return $this
358100
public function cascade(array $cascade)
    {
        foreach ($cascade as $name) {
            $method = 'cascade'.Inflector::classify(strtolower($name));

            if (!method_exists($this->association, $method)) {
                throw new InvalidArgumentException('Cascade ['.$name.'] does not exist');
            }

            $this->{$method}();
        }

        return $this;
    }
661599
public function clear(array $keys=null)
    {
        if ($keys === null) {
            foreach ($this->storages as $storage) {
                $storage->clear();
            }
            return $this;
        }

        if (!$keys) {
            return $this;
        }

        foreach ($keys as $key) {
            $this->offsetUnset($key);
        }

        return $this;
    }
597254
public function together($relation)
    {
        if (is_string($relation)) {
            $relation = explode(',', $relation);
        }

        $this->together = $relation;

        $this->checkAutoRelationWrite();

        return $this;
    }
322124
private function cascadeRefresh(object $document, array &$visited) : void
    {
        $class = $this->dm->getClassMetadata(get_class($document));

        $associationMappings = array_filter(
            $class->associationMappings,
            static function ($assoc) {
                return $assoc['isCascadeRefresh'];
            }
        );

        foreach ($associationMappings as $mapping) {
            $relatedDocuments = $class->reflFields[$mapping['fieldName']]->getValue($document);
            if ($relatedDocuments instanceof Collection || is_array($relatedDocuments)) {
                if ($relatedDocuments instanceof PersistentCollectionInterface) {
                    // Unwrap so that foreach() does not initialize
                    $relatedDocuments = $relatedDocuments->unwrap();
                }
                foreach ($relatedDocuments as $relatedDocument) {
                    $this->doRefresh($relatedDocument, $visited);
                }
            } elseif ($relatedDocuments !== null) {
                $this->doRefresh($relatedDocuments, $visited);
            }
        }
    }
366629
public function restore($cascade_restore = null)
	{
		$deleted_column = static::soft_delete_property('deleted_field', static::$_default_field_name);
		$this->{$deleted_column} = null;

		//Loop through all relations and delete if we are cascading.
		$this->freeze();
		foreach ($this->relations() as $rel_name => $rel)
		{
			//get the cascade delete status
			$rel_cascade = is_null($cascade_restore) ? $rel->cascade_delete : (bool)$cascade_restore;

			//Make sure that the other model is soft delete too
			if ($rel_cascade)
			{
				if (! is_subclass_of($rel->model_to, 'Orm\Model_Soft'))
				{
					//Throw if other is not soft
					throw new RelationNotSoft('Both sides of the relation must be subclasses of Model_Soft if cascade delete is true');
				}

				if (get_class($rel) != 'Orm\ManyMany')
				{
					$model_to = $rel->model_to;
					$model_to::disable_filter();

					//Loop through and call restore on all the models
					foreach ($rel->get($this) as $model)
					{
						$model->restore($cascade_restore);
					}

					$model_to::enable_filter();
				}
			}
		}
		$this->unfreeze();

		return $this->save();
	}
1292382
public function _mergeWithPrevious($previous)
    {
        if (!$previous)
        {
            return $this;
        }
        if ($previous instanceof DeleteOperation)
        {
            return new SetOperation($this->objects);
        }
        if ($previous instanceof SetOperation)
        {
            $oldList = $previous->getValue();

            return new SetOperation(array_merge((array) $oldList, (array) $this->objects));
        }
        if ($previous instanceof AddOperation)
        {
            $oldList = $previous->getValue();

            return new SetOperation(array_merge((array) $oldList, (array) $this->objects));
        }
        throw new AVException('Operation is invalid after previous operation.');
    }
889540
public function remove($key)
    {
        if ($this->has($key)) {
            $cont = clone $this;
            $cont->doRemove($key);

            return $cont;
        }

        return $this;
    }
1067344
public function merge($data)
    {
        foreach ($data as $key => $val) {
            if ($key === 'paths') {
                $this->addPaths((array)$val);
            } elseif ($key === 'cache') {
                $this->setCache($val);
            } else {
                $this->offsetReplace($key, $val);
            }
        }

        return $this;
    }
946183
public function load($relation)
    {
        $item = current($this->items);
        $item->eagerlyResultSet($this->items, $relation);

        return $this;
    }
873236
public function remove( $classs ) {
		if ( isset( $this->mapping[ $classs ] ) ) {
			unset( $this->mapping[ $classs ] );
		}
		return $this;
	}
1238338
private function cascadeRefresh($entity, array &$visited)
    {
        $class = $this->em->getClassMetadata(get_class($entity));

        foreach ($class->getDeclaredPropertiesIterator() as $association) {
            if (! ($association instanceof AssociationMetadata && in_array('refresh', $association->getCascade(), true))) {
                continue;
            }

            $relatedEntities = $association->getValue($entity);

            switch (true) {
                case $relatedEntities instanceof PersistentCollection:
                    // Unwrap so that foreach() does not initialize
                    $relatedEntities = $relatedEntities->unwrap();
                    // break; is commented intentionally!

                case $relatedEntities instanceof Collection:
                case is_array($relatedEntities):
                    foreach ($relatedEntities as $relatedEntity) {
                        $this->doRefresh($relatedEntity, $visited);
                    }
                    break;

                case $relatedEntities !== null:
                    $this->doRefresh($relatedEntities, $visited);
                    break;

                default:
                    // Do nothing
            }
        }
    }
320119
public function remove($key)
    {
        if ($this->has($key)) {
            $cont = clone $this;
            $cont->removeParameter($key);

            return $cont;
        }

        return $this;
    }
951212
public function mergeBindings(self $query)
    {
        $this->bindings = array_merge_recursive($this->bindings, $query->bindings);

        return $this;
    }
233135
public function remove($key): self
    {
        // recursive call
        if (\is_array($key)) {
            foreach ($key as $k) {
                $this->internalRemove($k);
            }

            return static::create(
                $this->getArray(),
                $this->iteratorClass,
                false
            );
        }

        $this->internalRemove($key);

        return static::create(
            $this->getArray(),
            $this->iteratorClass,
            false
        );
    }
90894
public function merge( array ...$array_to_merge ) : self {

		foreach ( $array_to_merge as $arr ) {
			$items = array_replace_recursive( $this->getArrayCopy(), $arr );

			foreach ( $items as $key => $value ) {
				$this->offsetSet( $key, $value );
			}
		}

		return $this;
	}
249430
public function remove($listener)
    {
        if ($this->storage->contains($listener)) {
            $this->storage->detach($listener);
            $this->storage->rewind();

            $this->queue = new \SplPriorityQueue();

            foreach ($this->storage as $listener) {
                $priority = $this->storage->getInfo();
                $this->queue->insert($listener, $priority);
            }
        }

        return $this;
    }
437293
public function restore($key = null)
    {
        if (is_null($key)) {
            $mergedData         = array_merge($this->_DATA, $this->_originalDATA);
            $this->_DATA        = $this->_removeNewKeys($mergedData);
            $this->_dataChanged = false;
            $this->_newKeys     = [];
        } else {
            if (array_key_exists($key, $this->_originalDATA)) {
                $this->_DATA[$key] = $this->_originalDATA[$key];
            }
        }

        return $this;
    }