/** * Actual logic for setting an element in the collection. * * @param mixed $offset * @param mixed $value * @param bool $arrayAccess * @return bool */ private function doSet($offset, $value, $arrayAccess) { $arrayAccess ? $this->coll->offsetSet($offset, $value) : $this->coll->set($offset, $value); // Handle orphanRemoval if ($this->uow !== null && $this->isOrphanRemovalEnabled() && $value !== null) { $this->uow->unscheduleOrphanRemoval($value); } $this->changed(); }
/** * {@inheritdoc} */ public function add($value) { /* Initialize the collection before calling add() so this append operation * uses the appropriate key. Otherwise, we risk overwriting original data * when $newObjects are re-added in a later call to initialize(). */ if (isset($this->mapping['strategy']) && CollectionHelper::isHash($this->mapping['strategy'])) { $this->initialize(); } $this->coll->add($value); $this->changed(); if ($this->uow !== null && $this->isOrphanRemovalEnabled() && $value !== null) { $this->uow->unscheduleOrphanRemoval($value); } return true; }