Completed
Pull Request — master (#247)
by Tomáš
02:52
created

CommandHelper   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 0
cbo 5
dl 0
loc 23
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A setApplicationEntityManager() 0 9 1
1
<?php
2
3
/**
4
 * This file is part of the Kdyby (http://www.kdyby.org)
5
 *
6
 * Copyright (c) 2008 Filip Procházka ([email protected])
7
 *
8
 * For the full copyright and license information, please view the file license.txt that was distributed with this source code.
9
 */
10
11
namespace Kdyby\Doctrine\Console;
12
13
use Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper;
14
use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper;
15
use Kdyby\Console\ContainerHelper;
16
17
18
19
/**
20
 * @author Tomáš Jacík <[email protected]>
21
 */
22
final class CommandHelper
23
{
24
25
	/**
26
	 * Private constructor. This class is not meant to be instantiated.
27
	 */
28
	private function __construct()
29
	{
30
	}
31
32
33
34
	public static function setApplicationEntityManager(ContainerHelper $containerHelper, $emName)
35
	{
36
		/** @var \Kdyby\Doctrine\EntityManager $em */
37
		$em = $containerHelper->getByType('Kdyby\Doctrine\Registry')->getManager($emName);
38
		/** @var \Symfony\Component\Console\Helper\HelperSet $helperSet */
39
		$helperSet = $containerHelper->getHelperSet();
40
		$helperSet->set(new ConnectionHelper($em->getConnection()), 'db');
41
		$helperSet->set(new EntityManagerHelper($em), 'em');
42
	}
43
44
}
45