Inheritance: extends IteratorAggregat\IteratorAggregate, extends Countabl\Countable
 public function getIterator(IEntity $parent, ICollection $collection)
 {
     if ($this->metadata->relationship->isMain) {
         $relationshipData = $this->mapper->getRelationshipDataStorage($this->metadata->name);
         $ids = isset($relationshipData[$parent->id]) ? array_keys($relationshipData[$parent->id]) : [];
     } else {
         $ids = [];
         $parentId = $parent->id;
         $relationshipData = $this->mapper->getRelationshipDataStorage($this->metadata->relationship->property);
         foreach ($relationshipData as $id => $parentIds) {
             if (isset($parentIds[$parentId])) {
                 $ids[] = $id;
             }
         }
     }
     $data = $collection->findBy(['id' => $ids])->fetchAll();
     return new EntityIterator($data);
 }
 public function getIterator(IEntity $parent, ICollection $collection)
 {
     $key = $parent->getRawValue($this->metadata->name);
     return [$key ? $collection->getBy(['id' => $key]) : NULL];
 }
 public function getIterator(IEntity $parent, ICollection $collection)
 {
     $data = $collection->findBy(["this->{$this->joinStorageKey}->id" => $parent->getValue('id')])->fetchAll();
     return new EntityIterator($data);
 }
 protected function applyDefaultOrder(ICollection $collection)
 {
     if ($this->metadata->relationship->order !== NULL) {
         return $collection->orderBy($this->metadata->relationship->order[0], $this->metadata->relationship->order[1]);
     } else {
         return $collection;
     }
 }
Example #5
0
 public function getIterator() : IteratorAggregate
 {
     return $this->collection->limitBy($this->paginator->getItemsPerPage(), $this->paginator->getOffset()) ?: parent::getIterator();
 }