Skip to content

Commit 93f553f

Browse files
committed
Adding getDriver to repository
1 parent d790334 commit 93f553f

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ All the methods listed under MongoDBWriteRepository, MongoDBReadRepository and M
258258
- `public function transactional(callable $transaction)`
259259
- `public function count(Filter $filter = null)`
260260
- `public function exists(Identity $id)`
261+
- `public function getDriver()`
261262

262263
### Available in MongoDBReadRepository
263264

@@ -266,12 +267,14 @@ All the methods listed under MongoDBWriteRepository, MongoDBReadRepository and M
266267
- `public function findByDistinct(Fields $distinctFields, Filter $filter = null, Sort $sort = null, Fields $fields = null)`
267268
- `public function count(Filter $filter = null)`
268269
- `public function exists(Identity $id)`
270+
- `public function getDriver()`
269271

270272
### Available in MongoDBPageRepository
271273

272274
- `public function findAll(Pageable $pageable = null)`
273275
- `public function count(Filter $filter = null)`
274276
- `public function exists(Identity $id)`
277+
- `public function getDriver()`
275278

276279
---
277280

src/Infrastructure/Model/Repository/MongoDB/BaseMongoDBRepository.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ public static function create(Mapping $mapping, Client $client, $databaseName, $
7979
return new static($mapping, $client, $databaseName, $collectionName, $options);
8080
}
8181

82+
/**
83+
* @return \MongoDB\Collection
84+
*/
85+
public function getDriver()
86+
{
87+
return $this->getCollection();
88+
}
89+
8290
/**
8391
* @return \MongoDB\Collection
8492
*/

src/Infrastructure/Model/Repository/MongoDB/MongoDBRepository.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,14 @@ public function __construct(Mapping $mapping, Client $client, $databaseName, $co
110110
);
111111
}
112112

113+
/**
114+
* @return \MongoDB\Collection
115+
*/
116+
public function getDriver()
117+
{
118+
return $this->readRepository->getDriver();
119+
}
120+
113121
/**
114122
* Returns the total amount of elements in the repository given the restrictions provided by the Filter object.
115123
*

tests/Infrastructure/Model/Repository/MongoDB/MongoDBRepositoryTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ public function setUp()
5252
$this->repository->addAll([$client1, $client2, $client3, $client4]);
5353
}
5454

55+
56+
public function testGetDriver()
57+
{
58+
$this->assertInstanceOf('\MongoDB\Collection', $this->repository->getDriver());
59+
}
60+
5561
public function testItCanUpdateAnExistingClient()
5662
{
5763
$client1 = new Clients(1, 'Homer Simpson', new DateTime('2014-12-11'), 3, 25.125);

0 commit comments

Comments
 (0)