本文整理匯總了PHP中Doctrine\Common\Collections\Collection::remove方法的典型用法代碼示例。如果您正苦於以下問題:PHP Collection::remove方法的具體用法?PHP Collection::remove怎麽用?PHP Collection::remove使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine\Common\Collections\Collection
的用法示例。
在下文中一共展示了Collection::remove方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: removeProduct
/**
* Remove a product from the basket.
*
* @param Product $product
* @param int $nb
*
* @return $this
*/
public function removeProduct(Product $product, $nb = 1)
{
if ($this->products->containsKey($product->getId())) {
$this->decreaseNbProduct($product, $nb);
$nbLeft = $this->getNbProduct($product);
if (0 >= $nbLeft) {
$this->products->remove($product->getId());
}
}
return $this;
}
示例2: intersectUnion
/**
* This function performs a kind of "intersection union" operation, and is useful especially when dealing
* with dynamic forms. For instance, if a collection contains existing elements and a form remove one of those
* elements, this function will return a Collection that contains all the elements from $collection1, minus ones
* that are not present in $collection2. This is used internally in the DoctrineModule hydrator, so that the
* work is done for you automatically
*
* @param Collection $collection1
* @param Collection $collection2
* @return Collection
*/
public static function intersectUnion(Collection $collection1, Collection $collection2)
{
// Don't make the work both
if ($collection1 === $collection2) {
return $collection1;
}
$toRemove = array();
foreach ($collection1 as $key1 => $value1) {
$elementFound = false;
foreach ($collection2 as $key2 => $value2) {
if ($value1 === $value2) {
$elementFound = true;
unset($collection2[$key2]);
break;
}
}
if (!$elementFound) {
$toRemove[] = $key1;
}
}
// Remove elements that are in $collection1 but not in $collection2
foreach ($toRemove as $key) {
$collection1->remove($key);
}
// Add elements that are in $collection2 but not in $collection1
foreach ($collection2 as $value) {
$collection1->add($value);
}
return $collection1;
}
示例3: remove
/**
* Removes the element at the specified index from the collection.
*
* @param string|integer $key The kex/index of the element to remove.
*
* @return mixed The removed element or NULL, if the collection did not contain the element.
*/
function remove($key)
{
$this->initialize();
$element = $this->collection->remove($key);
if ($element) {
$this->setDirty(true);
}
return $element;
}
示例4: testRemove
public function testRemove()
{
$this->_coll[] = 'one';
$this->_coll[] = 'two';
$el = $this->_coll->remove(0);
$this->assertEquals('one', $el);
$this->assertEquals($this->_coll->contains('one'), false);
$this->assertNull($this->_coll->remove(0));
}
示例5: remove
/**
* {@inheritdoc}
*/
public function remove($key)
{
$this->initialize();
$removed = $this->coll->remove($key);
if (!$removed) {
return $removed;
}
$this->changed();
return $removed;
}
示例6: doRemove
/**
* Actual logic for removing element by its key.
*
* @param mixed $offset
* @param bool $arrayAccess
* @return mixed|void
*/
private function doRemove($offset, $arrayAccess)
{
$this->initialize();
$removed = $arrayAccess ? $this->coll->offsetUnset($offset) : $this->coll->remove($offset);
if (!$removed && !$arrayAccess) {
return $removed;
}
$this->changed();
return $removed;
}
示例7: remove
/**
* {@inheritdoc}
*/
public function remove($key)
{
$this->initialize();
$removed = $this->coll->remove($key);
if ($removed) {
$this->changed();
if ($this->isOrphanRemovalEnabled()) {
$this->uow->scheduleOrphanRemoval($removed);
}
}
return $removed;
}
示例8: removeModifier
public function removeModifier(string $name)
{
$this->modifiers->remove($name);
}
示例9: remove
public function remove($key)
{
$this->initialize();
$this->changed = true;
return $this->col->remove($key);
}
示例10: remove
/**
* {@inheritdoc}
*/
public function remove($key)
{
// TODO: If the keys are persistent as well (not yet implemented)
// and the collection is not initialized and orphanRemoval is
// not used we can issue a straight SQL delete/update on the
// association (table). Without initializing the collection.
$this->initialize();
$removed = $this->coll->remove($key);
if ($removed) {
$this->changed();
if ($this->association !== null && $this->association['type'] == ClassMetadata::ONE_TO_MANY && $this->association['orphanRemoval']) {
$this->em->getUnitOfWork()->scheduleOrphanRemoval($removed);
}
}
return $removed;
}
示例11: removeChild
/**
* {@inheritdoc}
*/
public function removeChild($name)
{
$name = $name instanceof ItemInterface ? $name->getName() : $name;
$child = $this->getChild($name);
if ($child !== null) {
$child->setParent(null);
$this->children->remove($name);
}
return $this;
}
示例12: removeReview
/**
* {@inheritdoc}
*/
public function removeReview(ReviewInterface $review)
{
$this->reviews->remove($review);
}
示例13: removeSetting
/**
* Remove setting.
*
* @param RoleSettingInterface $setting
*/
public function removeSetting(RoleSettingInterface $setting)
{
$this->settings->remove($setting->getKey());
}
示例14: removeThirdParty
/**
* @param ThirdParty $thirdParty
*
* @return bool
*/
public function removeThirdParty(ThirdParty $thirdParty)
{
return (bool) $this->thirdPartyCredentials->remove($thirdParty);
}
示例15: removeLesson
/**
* @param Lesson $lesson
*/
public function removeLesson(Lesson $lesson)
{
$this->lessons->remove($lesson);
}