本文整理汇总了PHP中Doctrine\Common\Collections\ArrayCollection::remove方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayCollection::remove方法的具体用法?PHP ArrayCollection::remove怎么用?PHP ArrayCollection::remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Collections\ArrayCollection
的用法示例。
在下文中一共展示了ArrayCollection::remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: toMany
/**
* @param mixed $valueOrObject
* @param string $target
* @return array
*/
protected function toMany($valueOrObject, $target, Collection $collection = null, $depth = 2)
{
if (!is_array($valueOrObject) && !$valueOrObject instanceof Traversable) {
$valueOrObject = (array) $valueOrObject;
}
if (!$collection instanceof Collection) {
$collection = new ArrayCollection();
}
$keepers = array();
foreach ($valueOrObject as $value) {
if (method_exists($value, 'toArray')) {
$value = $value->toArray($depth);
} else {
if (!is_array($value) && !$value instanceof Traversable) {
$value = (array) $value;
}
}
if (isset($value['id']) && strlen($value['id']) && ($found = $this->find($target, $value['id']))) {
$keepers[] = $found->id;
$this->hydrate($value, $found);
} else {
$obj = new $target();
$obj->fromArray($value);
$obj->id = null;
if ($collection instanceof PersistentCollection) {
if ($owner = $collection->getOwner()) {
$mapping = $collection->getMapping();
$mappedBy = $mapping['mappedBy'];
$obj->{$mappedBy} = $owner;
}
}
$collection->add($obj);
}
}
$collection->forAll(function ($key, $element) use($collection, $keepers) {
if (strlen($element->id) && !in_array($element->id, $keepers)) {
$collection->remove($key);
}
});
return $collection;
}
示例2: remove
/**
* @param Car $car
* @return boolean
*/
public function remove(Car $car)
{
if (!$this->has($car)) {
return false;
}
$this->cars->remove($car->getId());
$this->session->set('cart', $this->cars);
return true;
}
示例3: removeMember
/**
* @param string $member
* @return GroupOfNames
*/
public function removeMember($member)
{
foreach ($this->members as $attr) {
if ($attr->get() == $member) {
$this->members->remove($attr);
return $this;
}
}
return $this;
}
示例4: removeJoueurs
/**
* @param ArrayCollection $joueurs
* @return Ligue $this
*/
public function removeJoueurs($joueurs)
{
foreach ($joueurs as $joueur) {
$this->joueurs->remove($joueur);
}
return $this;
}
示例5: removeChild
/**
* Removes child channel from collection
*
* @param CircularReferenceEntity $child child
*
* @return void
*/
private function removeChild(CircularReferenceEntity $child)
{
$index = $this->getChildren()->indexOf($child);
if ($index !== false) {
$this->Children->remove($index);
}
}
示例6: remove
public function remove($key)
{
if (null === $this->entries) {
$this->__load___();
}
return $this->entries->remove($key);
}
示例7: removeQuestion
public function removeQuestion(SurveyQuestion $question)
{
if ($this->questions->contains($question)) {
$this->questions->remove($question);
$question->setSurvey(null);
}
}
示例8: removeTaxonomy
/**
* @param TermTaxonomy $taxonomy
*
* @return Term
*/
public function removeTaxonomy(TermTaxonomy $taxonomy)
{
if ($this->taxonomies->contains($taxonomy)) {
$this->taxonomies->remove($taxonomy);
}
return $this;
}
示例9: remove
/**
* {@inheritdoc}
*/
public function remove($key)
{
foreach ($this->fields as $managerName => $method) {
call_user_func(array(self::getElementMethod($this->model, $managerName, $method), 'remove'), $key);
}
return parent::remove($key);
}
示例10: removeRelationship
/**
* @param TermRelationships $relationship
*
* @return Term
*/
public function removeRelationship(TermRelationships $relationship)
{
if ($this->relationships->contains($relationship)) {
$this->relationships->remove($relationship);
}
return $this;
}
示例11: removeReport
public function removeReport(ReportModule $reportModule)
{
$index = $this->modules->indexOf($reportModule);
if ($index !== null) {
$this->modules->remove($index);
}
return $this;
}
示例12: removeCourse
public function removeCourse(CourseModule $courseModule)
{
$index = $this->modules->indexOf($courseModule);
if ($index !== null) {
$this->modules->remove($index);
}
return $this;
}
示例13: remove
/**
* {@inheritdoc}
*/
public function remove($key)
{
$removedElement = parent::remove($key);
if (null !== $removedElement) {
unset($this->keys[(string) $removedElement]);
}
return $removedElement;
}
示例14: setProcessed
/**
* @param $item
* @param $key
*/
protected function setProcessed(ImportItemProcess $item, $key)
{
$this->entityManager->remove($item);
$this->itemProcessCollection->remove($key);
$this->importLog->addProcessItemCount();
$this->processedItemCount++;
$index = $item->getItemIndex();
$this->setItemLogIndex($index);
}
示例15: drop
/**
* Drops a Collection - removing all data
*
* @param string $collection The name of the Collection to drop
*/
public function drop($collection)
{
if (!$this->collections->containsKey($collection)) {
return false;
}
$this->collections->get($collection)->drop();
$this->collections->remove($collection);
return true;
}