| @@ 23-48 (lines=26) @@ | ||
| 20 | * @author Karel Osorio Ramírez <[email protected]> |
|
| 21 | * @author Ivannis Suárez Jerez <[email protected]> |
|
| 22 | */ |
|
| 23 | class DataSourceList extends LazyList |
|
| 24 | { |
|
| 25 | use DataSourceCollectionTrait; |
|
| 26 | ||
| 27 | /** |
|
| 28 | * {@inheritdoc} |
|
| 29 | */ |
|
| 30 | public function findOne(SpecificationInterface $criteria) |
|
| 31 | { |
|
| 32 | if ($this->isInitialized()) { |
|
| 33 | return parent::findOne($criteria); |
|
| 34 | } |
|
| 35 | ||
| 36 | return $this->dataSource->filteredDataSource($criteria)->findOne(); |
|
| 37 | } |
|
| 38 | ||
| 39 | /** |
|
| 40 | * {@inheritdoc} |
|
| 41 | */ |
|
| 42 | protected function initialize() |
|
| 43 | { |
|
| 44 | $this->collection = new ArrayList(); |
|
| 45 | ||
| 46 | $this->collection->addAll($this->dataSource->getIterator()); |
|
| 47 | } |
|
| 48 | } |
|
| 49 | ||
| @@ 23-48 (lines=26) @@ | ||
| 20 | * @author Karel Osorio Ramírez <[email protected]> |
|
| 21 | * @author Ivannis Suárez Jerez <[email protected]> |
|
| 22 | */ |
|
| 23 | class DataSourceSet extends LazySet |
|
| 24 | { |
|
| 25 | use DataSourceCollectionTrait; |
|
| 26 | ||
| 27 | /** |
|
| 28 | * {@inheritdoc} |
|
| 29 | */ |
|
| 30 | public function findOne(SpecificationInterface $criteria) |
|
| 31 | { |
|
| 32 | if ($this->isInitialized()) { |
|
| 33 | return parent::findOne($criteria); |
|
| 34 | } |
|
| 35 | ||
| 36 | return $this->dataSource->filteredDataSource($criteria)->findOne(); |
|
| 37 | } |
|
| 38 | ||
| 39 | /** |
|
| 40 | * {@inheritdoc} |
|
| 41 | */ |
|
| 42 | protected function initialize() |
|
| 43 | { |
|
| 44 | $this->collection = new ArraySet(); |
|
| 45 | ||
| 46 | $this->collection->addAll($this->dataSource->getIterator()); |
|
| 47 | } |
|
| 48 | } |
|
| 49 | ||