-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
164 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Cubiche package. | ||
* | ||
* Copyright (c) Cubiche | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Cubiche\Infrastructure\Repository\Doctrine\ODM\MongoDB; | ||
|
||
use Doctrine\ODM\MongoDB\DocumentManager; | ||
|
||
/** | ||
* DocumentQueryRepositoryFactory class. | ||
* | ||
* @author Ivannis Suárez Jerez <ivannis.suarez@gmail.com> | ||
*/ | ||
class DocumentQueryRepositoryFactory implements DocumentQueryRepositoryFactoryInterface | ||
{ | ||
/** | ||
* @var DocumentManager | ||
*/ | ||
protected $documentManager; | ||
|
||
/** | ||
* @var DocumentDataSourceFactory | ||
*/ | ||
protected $documentDatasourceFactory; | ||
|
||
/** | ||
* DocumentQueryRepositoryFactory constructor. | ||
* | ||
* @param DocumentManager $documentManager | ||
* @param DocumentDataSourceFactory $documentDatasourceFactory | ||
*/ | ||
public function __construct(DocumentManager $documentManager, DocumentDataSourceFactory $documentDatasourceFactory) | ||
{ | ||
$this->documentManager = $documentManager; | ||
$this->documentDatasourceFactory = $documentDatasourceFactory; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function create($documentName) | ||
{ | ||
return new DocumentQueryRepository( | ||
$this->documentManager->getRepository($documentName), | ||
$this->documentDatasourceFactory | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Cubiche package. | ||
* | ||
* Copyright (c) Cubiche | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Cubiche\Infrastructure\Repository\Doctrine\ODM\MongoDB; | ||
|
||
/** | ||
* DocumentQueryRepositoryFactory interface. | ||
* | ||
* @author Ivannis Suárez Jerez <ivannis.suarez@gmail.com> | ||
*/ | ||
interface DocumentQueryRepositoryFactoryInterface | ||
{ | ||
/** | ||
* @param string $documentName | ||
* | ||
* @return DocumentQueryRepository | ||
*/ | ||
public function create($documentName); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Cubiche package. | ||
* | ||
* Copyright (c) Cubiche | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Cubiche\Infrastructure\Repository\Doctrine\ODM\MongoDB; | ||
|
||
use Doctrine\ODM\MongoDB\DocumentManager; | ||
|
||
/** | ||
* DocumentRepositoryFactory class. | ||
* | ||
* @author Ivannis Suárez Jerez <ivannis.suarez@gmail.com> | ||
*/ | ||
class DocumentRepositoryFactory implements DocumentRepositoryFactoryInterface | ||
{ | ||
/** | ||
* @var DocumentManager | ||
*/ | ||
protected $documentManager; | ||
|
||
/** | ||
* @var DocumentDataSourceFactory | ||
*/ | ||
protected $documentDatasourceFactory; | ||
|
||
/** | ||
* DocumentRepositoryFactory constructor. | ||
* | ||
* @param DocumentManager $documentManager | ||
* @param DocumentDataSourceFactory $documentDatasourceFactory | ||
*/ | ||
public function __construct(DocumentManager $documentManager, DocumentDataSourceFactory $documentDatasourceFactory) | ||
{ | ||
$this->documentManager = $documentManager; | ||
$this->documentDatasourceFactory = $documentDatasourceFactory; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function create($documentName) | ||
{ | ||
return new DocumentRepository( | ||
$this->documentManager->getRepository($documentName), | ||
$this->documentDatasourceFactory | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Cubiche package. | ||
* | ||
* Copyright (c) Cubiche | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Cubiche\Infrastructure\Repository\Doctrine\ODM\MongoDB; | ||
|
||
/** | ||
* DocumentRepositoryFactory interface. | ||
* | ||
* @author Ivannis Suárez Jerez <ivannis.suarez@gmail.com> | ||
*/ | ||
interface DocumentRepositoryFactoryInterface | ||
{ | ||
/** | ||
* @param string $documentName | ||
* | ||
* @return DocumentRepository | ||
*/ | ||
public function create($documentName); | ||
} |