1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
4
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
5
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
6
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
7
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
8
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
9
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
10
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
11
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
12
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
13
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
14
|
|
|
* |
15
|
|
|
* This software consists of voluntary contributions made by many individuals |
16
|
|
|
* and is licensed under the MIT license. For more information, see |
17
|
|
|
* <http://www.doctrine-project.org>. |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
namespace Saxulum\DoctrineMongodbOdmCommands\Helper; |
21
|
|
|
|
22
|
|
|
use Symfony\Component\Console\Helper\Helper; |
23
|
|
|
use Doctrine\Common\Persistence\ManagerRegistry; |
24
|
|
|
|
25
|
|
|
class ManagerRegistryHelper extends Helper |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* @var ManagerRegistry |
29
|
|
|
*/ |
30
|
|
|
protected $managerRegistry; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @param ManagerRegistry $managerRegistry |
34
|
|
|
*/ |
35
|
|
|
public function __construct(ManagerRegistry $managerRegistry) |
36
|
|
|
{ |
37
|
|
|
$this->managerRegistry = $managerRegistry; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @param $name |
42
|
|
|
* @return \Doctrine\Common\Persistence\ObjectManager |
43
|
|
|
*/ |
44
|
|
|
public function getManager($name) |
45
|
|
|
{ |
46
|
|
|
return $this->managerRegistry->getManager($name); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @return string |
51
|
|
|
*/ |
52
|
|
|
public function getDefaultManagerName() |
53
|
|
|
{ |
54
|
|
|
return $this->managerRegistry->getDefaultManagerName(); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @param $name |
59
|
|
|
* @return object |
60
|
|
|
*/ |
61
|
|
|
public function getConnection($name) |
62
|
|
|
{ |
63
|
|
|
return $this->managerRegistry->getConnection($name); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @return string |
68
|
|
|
*/ |
69
|
|
|
public function getName() |
70
|
|
|
{ |
71
|
|
|
return 'managerregistry'; |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|