/** * Adds an element to the internal $collNestedSetChildren collection. * Beware that this doesn't insert a node in the tree. * This method is only used to facilitate children hydration. * * @param Page $page * * @return void */ public function addNestedSetChild($page) { if ($this->collNestedSetChildren === null) { $this->initNestedSetChildren(); } if (!in_array($page, $this->collNestedSetChildren->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->collNestedSetChildren[] = $page; $page->setParent($this); } }
public function testCollectionRemoveDoesNothingWhenObjectIsNotFound() { $manager = new ModelManager(); $object = new \stdClass(); $object->foo = 42; $otherObject = new \stdClass(); $otherObject->bar = 'baz'; $collection = new \PropelObjectCollection(); $collection->append($object); $this->assertSame(array($object), $collection->getArrayCopy()); $manager->collectionRemoveElement($collection, $otherObject); $this->assertSame(array($object), $collection->getArrayCopy()); }