Completed
Push — master ( 2fb092...058edd )
by Craig
06:38
created

AbstractRoutesFactory::getRepository()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Routes.
4
 *
5
 * @copyright Zikula contributors (Zikula)
6
 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
7
 * @author Zikula contributors <[email protected]>.
8
 * @link http://www.zikula.org
9
 * @link http://zikula.org
10
 * @version Generated by ModuleStudio 0.7.1 (http://modulestudio.de).
11
 */
12
13
namespace Zikula\RoutesModule\Entity\Factory\Base;
14
15
use Doctrine\Common\Persistence\ObjectManager;
16
use Doctrine\ORM\EntityRepository;
17
18
/**
19
 * Factory class used to create entities and receive entity repositories.
20
 *
21
 * This is the base factory class.
22
 */
23
abstract class AbstractRoutesFactory
24
{
25
    /**
26
     * @var ObjectManager The object manager to be used for determining the repository
27
     */
28
    protected $objectManager;
29
30
    /**
31
     * RoutesFactory constructor.
32
     *
33
     * @param ObjectManager $objectManager The object manager to be used for determining the repositories
34
     */
35
    public function __construct(ObjectManager $objectManager)
36
    {
37
        $this->objectManager = $objectManager;
38
    }
39
40
    /**
41
     * Returns a repository for a given object type.
42
     *
43
     * @param string $objectType Name of desired entity type
44
     *
45
     * @return EntityRepository The repository responsible for the given object type
46
     */
47
    public function getRepository($objectType)
48
    {
49
        $entityClass = 'Zikula\\RoutesModule\\Entity\\' . ucfirst($objectType) . 'Entity';
50
51
        return $this->objectManager->getRepository($entityClass);
52
    }
53
54
    /**
55
     * Creates a new route instance.
56
     *
57
     * @return Zikula\RoutesModule\Entity\routeEntity The newly created entity instance
58
     */
59
    public function createRoute()
60
    {
61
        $entityClass = 'Zikula\\RoutesModule\\Entity\\routeEntity';
62
63
        return new $entityClass();
64
    }
65
66
    /**
67
     * Returns the object manager.
68
     *
69
     * @return ObjectManager
70
     */
71
    public function getObjectManager()
72
    {
73
        return $this->objectManager;
74
    }
75
    
76
    /**
77
     * Sets the object manager.
78
     *
79
     * @param ObjectManager $objectManager
80
     *
81
     * @return void
82
     */
83
    public function setObjectManager($objectManager)
84
    {
85
        $this->objectManager = $objectManager;
86
    }
87
    
88
}
89