Remove a model from a collection

@param \Model                 $objModel
@param \Model\Collection|null $objCollection

@return \Model\Collection|null
430627
public static function removeModelFromCollection(\Model $objModel, \Model\Collection $objCollection = null)
    {
        $arrRegistered = [];

        if ($objCollection !== null)
        {
            while ($objCollection->next())
            {
                if ($objCollection->getTable() !== $objModel->getTable)
                {
                    return $objCollection;
                }

                $intId = $objCollection->{$objModel::getPk()};

                if ($objModel->{$objModel::getPk()} == $intId)
                {
                    continue;
                }

                $arrRegistered[$intId] = $objCollection->current();
            }
        }

        return static::createCollection(array_filter(array_values($arrRegistered)), $objModel->getTable());
    }
682135
public function removeAll($obj = null)
    {
        if ($obj === null) {
            $this->removeAllExcept(new \SplObjectStorage);
        }
        parent::removeAll($obj);
    }
910627
public function scheduleCollectionDeletion(PersistentCollection $coll)
    {
        $coid = spl_object_id($coll);

        // TODO: if $coll is already scheduled for recreation ... what to do?
        // Just remove $coll from the scheduled recreations?
        unset($this->collectionUpdates[$coid]);

        $this->collectionDeletions[$coid] = $coll;
    }
1021401
def destroy(self, request, *args, **kwargs):
        
        obj = self.get_object()
        user = request.user

        if strtobool(request.query_params.get('delete_content', 'false')):
            for data in obj.data.all():
                if user.has_perm('edit_data', data):
                    data.delete()

            # If all data objects in an entity are removed, the entity may
            # have already been removed, so there is no need to call destroy.
            if not Entity.objects.filter(pk=obj.pk).exists():
                return Response(status=status.HTTP_204_NO_CONTENT)

        # NOTE: Collection's ``destroy`` method should be skiped, so we
        # intentionaly call it's parent.
        return super(CollectionViewSet, self).destroy(  # pylint: disable=no-member,bad-super-call
            request, *args, **kwargs
        )
354350
protected boolean deleteMultipleModel(Set<MODEL_ID> idCollection, boolean permanent) throws Exception {
        if (permanent) {
            server.deleteAllPermanent(modelType, idCollection);
        } else {
            server.deleteAll(modelType, idCollection);
        }
        return permanent;
    }
1312976
public function remove($object)
    {
        if (!is_object($object) || !($object instanceof $this->objectType)) {
            $type = (is_object($object) ? get_class($object) : gettype($object));
            throw new IllegalObjectTypeException('The value given to remove() was ' . $type . ' , however the ' . get_class($this) . ' can only handle ' . $this->objectType . ' instances.', 1517408067);
        }
        $this->entityManager->remove($object);
    }
718002
public function unsub($obj)
    {
        $this->detach($obj);
        if ($this->count() === 0) {
            if (($func = $this->deactCb) !== null) {
                $func($this);
            }
        }
        return $this;
    }
1339105
def removeFromCollection(objs)
      method = 'removeFromCollection'
      type = Boolean
      args = {:keys=>Rdio::keys(objs)}
      return_object type,method,args
    end
1219428
public function destroy($obj): void
    {
        // del metadata
        $id = $this->genID($obj);

        if (isset($this->metas[$id])) {
            unset($this->metas[$id]);
        }

        $obj = null;
    }
656373
@SuppressWarnings("unchecked")
	public static <T> Collection<T> removeAny(Collection<T> collection, T... elesRemoved) {
		collection.removeAll(newHashSet(elesRemoved));
		return collection;
	}
149440
private void deleteObject(final App app, final Object obj) throws FrameworkException {

		if (obj instanceof NodeInterface) {

			app.delete((NodeInterface)obj);
		}

		if (obj instanceof RelationshipInterface) {

			app.delete((RelationshipInterface)obj);
		}

		if (obj instanceof Iterable) {

			if (batched) {

				final Iterable iterable = (Iterable)obj;
				final Iterator iterator = iterable.iterator();
				int count               = 0;

				while (iterator.hasNext()) {

					try (final Tx tx = app.tx()) {

						while (iterator.hasNext()) {

							deleteObject(app, iterator.next());

							if ((++count % batchSize) == 0) {
								break;
							}
						}

						tx.success();
					}

					logger.debug("Committing batch after {} objects", count);

					// reset count
					count = 0;
				}


			} else {

				for (final Object o : (Iterable)obj) {

					deleteObject(app, o);
				}
			}
		}
	}
1151720
public function scheduleCollectionDeletion(PersistentCollectionInterface $coll) : void
    {
        $oid = spl_object_hash($coll);
        unset($this->collectionUpdates[$oid]);
        if (isset($this->collectionDeletions[$oid])) {
            return;
        }

        $this->collectionDeletions[$oid] = $coll;
        $this->scheduleCollectionOwner($coll);
    }
529570
public function delete()
    {
        if ($this->cID > 0) {
            $db = Loader::db();

            // First we delete all versions
            $vl = new VersionList($this);
            $vl->setItemsPerPage(-1);
            $vlArray = $vl->getPage();

            foreach ($vlArray as $v) {
                $v->delete();
            }

            $cID = $this->getCollectionID();

            $q = "delete from CollectionAttributeValues where cID = {$cID}";
            $db->query($q);

            $q = "delete from Collections where cID = '{$cID}'";
            $r = $db->query($q);

            try {
                $q = "delete from CollectionSearchIndexAttributes where cID = {$cID}";
                $db->query($q);
            } catch (\Exception $e) {
            }
        }
    }
279002
public static <D extends DestroyInterface> void
    cleanUp(Collection<D> destroyCollection) {
        JMOptional.getOptional(destroyCollection).ifPresent(
                collection -> collection.forEach(Destroyer::cleanUp));
    }
807063
private void performDeletion(final ClassDescriptor cld, final Object obj, final Identity oid, final boolean ignoreReferences) throws PersistenceBrokerException
    {
            // 1. delete dependend collections
            if (!ignoreReferences  && cld.getCollectionDescriptors().size() > 0)
            {
                deleteCollections(obj, cld.getCollectionDescriptors());
            }
            // 2. delete object from directly mapped table
            try
            {
                dbAccess.executeDelete(cld, obj); // use obj not oid to delete, BRJ
            }
            catch(OptimisticLockException e)
            {
                // ensure that the outdated object be removed from cache
                objectCache.remove(oid);
                throw e;
            }

            // 3. Add OID to the set of deleted objects
            deletedDuringTransaction.add(oid);

            // 4. delete dependend upon objects last to avoid FK violations
            if (cld.getObjectReferenceDescriptors().size() > 0)
            {
                deleteReferences(cld, obj, oid, ignoreReferences);
            }
            // remove obj from the object cache:
            objectCache.remove(oid);
    }
1135619
public function delete(PersistentCollectionInterface $coll)
    {
        $mapping = $coll->getMapping();
        if ($mapping->isInverseSide) {
            return; // ignore inverse side
        }
        if ($mapping->strategy === PropertyMetadata::STORAGE_STRATEGY_ATOMIC_SET) {
            throw new \UnexpectedValueException(sprintf('%s delete collection strategy should have been handled by DocumentPersister. Please report a bug in issue tracker', $mapping->strategy));
        }

        list($qb, $path, $parent) = $this->getQueryPathAndParent($coll);

        $path->remove();
        $this->executeQuery($qb, $parent);
    }
1334884
public function deleteProductCategories($collection)
	{
		$timeStamp = time();
		if (!is_array($collection)) {
			return $this->createException('InvalidParameterValueException', 'Invalid parameter value. Parameter must be an array collection', 'E:S:001');
		}
		$countDeleted = 0;
		foreach ($collection as $entry) {
			if ($entry instanceof BundleEntity\ProductCategory) {
				$this->em->remove($entry);
				$countDeleted++;
			} else {
				$response = $this->getProductCategory($entry);
				if (!$response->error->exist) {
					$this->em->remove($response->result->set);
					$countDeleted++;
				}
			}
		}
		if ($countDeleted < 0) {
			return new ModelResponse(null, 0, 0, null, true, 'E:E:001', 'Unable to delete all or some of the selected entries.', $timeStamp, time());
		}
		$this->em->flush();
		return new ModelResponse(null, 0, 0, null, false, 'S:D:001', 'Selected entries have been successfully removed from database.', $timeStamp, time());
	}