/** * Extracts a slice of $length elements starting at position $offset from the Collection. * * If $length is null it returns all elements from $offset to the end of the Collection. * Keys have to be preserved by this method. Calling this method will only return the * selected slice and NOT change the elements contained in the collection slice is called on. * * @param int $offset * @param int|null $length * * @return array */ public function slice($offset, $length = null) { if (!$this->initialized && !$this->isDirty && $this->association['fetch'] === ClassMetadata::FETCH_EXTRA_LAZY) { $persister = $this->em->getUnitOfWork()->getCollectionPersister($this->association); return $persister->slice($this, $offset, $length); } return parent::slice($offset, $length); }
/** * @param mixed $element * * @return bool */ public function add($element) { $element->setGrouping($this->grouping); return parent::add($element); }
/** * {@inheritdoc} */ public function set($key, $value) { $this->throwIfNotForm($value); parent::set($key, $value); }
/** * Loads a collection of entities in a one-to-many association. * * @param array $assoc * @param object $sourceEntity * @param AbstractLazyCollection $collection The collection to load/fill. * * @return Collection */ public function loadOneToManyCollection(array $assoc, $sourceEntity, AbstractLazyCollection $collection) { if ($collection instanceof ApiCollection) { foreach ($collection->getIterator() as $entity) { $this->metadata->getReflectionProperty($assoc['mappedBy'])->setValue($entity, $sourceEntity); } } return $collection; }
/** * {@inheritdoc} */ public function set($key, $value) { if (null === $key) { parent::add($value); } else { parent::set($key, $value); } $this->changed(); }
/** * {@inheritdoc} */ public function offsetSet($offset, $value) { $this->verifyTypeIntegrity($value); $this->verifyUnique($offset, $value); parent::offsetSet($offset, $value); }