1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the Cubiche package. |
5
|
|
|
* |
6
|
|
|
* Copyright (c) Cubiche |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
namespace Cubiche\Infrastructure\Repository\Doctrine\ODM\MongoDB; |
12
|
|
|
|
13
|
|
|
use Cubiche\Infrastructure\Repository\Doctrine\ODM\MongoDB\Query\ComparatorVisitorFactoryInterface; |
14
|
|
|
use Cubiche\Infrastructure\Repository\Doctrine\ODM\MongoDB\Query\SpecificationVisitorFactoryInterface; |
15
|
|
|
use Doctrine\ODM\MongoDB\DocumentManager; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Document Data Source Factory Class. |
19
|
|
|
* |
20
|
|
|
* @author Karel Osorio Ramírez <[email protected]> |
21
|
|
|
*/ |
22
|
|
|
class DocumentDataSourceFactory implements DocumentDataSourceFactoryInterface |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* @var DocumentManager |
26
|
|
|
*/ |
27
|
|
|
protected $dm; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var SpecificationVisitorFactoryInterface |
31
|
|
|
*/ |
32
|
|
|
protected $specificationVisitorFactory; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var ComparatorVisitorFactoryInterface |
36
|
|
|
*/ |
37
|
|
|
protected $comparatorVisitorFactory; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @param DocumentManager $dm |
41
|
|
|
* @param SpecificationVisitorFactoryInterface $specificationVisitorFactory |
42
|
|
|
* @param ComparatorVisitorFactoryInterface $comparatorVisitorFactory |
43
|
|
|
*/ |
44
|
|
|
public function __construct( |
45
|
|
|
DocumentManager $dm, |
46
|
|
|
SpecificationVisitorFactoryInterface $specificationVisitorFactory, |
47
|
|
|
ComparatorVisitorFactoryInterface $comparatorVisitorFactory |
48
|
|
|
) { |
49
|
|
|
$this->dm = $dm; |
50
|
|
|
$this->specificationVisitorFactory = $specificationVisitorFactory; |
51
|
|
|
$this->comparatorVisitorFactory = $comparatorVisitorFactory; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function create($documentName = null) |
55
|
|
|
{ |
56
|
|
|
return new DocumentDataSource( |
57
|
|
|
$this->dm, |
58
|
|
|
$this->specificationVisitorFactory, |
59
|
|
|
$this->comparatorVisitorFactory, |
60
|
|
|
$documentName |
61
|
|
|
); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|