1 | <?php |
||
14 | class FeatureManager { |
||
15 | /** @var EntityManager **/ |
||
16 | protected $em; |
||
17 | /** @var Slugger **/ |
||
18 | protected $slugger; |
||
19 | /** @var string **/ |
||
20 | protected $featureClass; |
||
21 | |||
22 | /** |
||
23 | * @param EntityManager $em |
||
24 | * @param string $featureClass |
||
25 | */ |
||
26 | 4 | public function __construct(EntityManager $em, Slugger $slugger, $featureClass) { |
|
31 | |||
32 | /** |
||
33 | * @param ProjectModel $project |
||
34 | * @return array |
||
35 | */ |
||
36 | 1 | public function getProjectFeatures(ProjectModel $project) { |
|
39 | |||
40 | /** |
||
41 | * @param integer $id |
||
42 | * @return FeatureModel |
||
43 | */ |
||
44 | 1 | public function getFeature($id) { |
|
50 | |||
51 | /** |
||
52 | * @param ProjectModel $project |
||
53 | * @param string $name |
||
54 | * @param string $description |
||
55 | * @param integer $status |
||
56 | * @param integer $productOwnerValue |
||
57 | * @param UserInterface $developer |
||
58 | * @return FeatureModel |
||
59 | */ |
||
60 | 1 | public function createProductOwnerFeature(ProjectModel $project, $name, $description, $status, $productOwnerValue = null, $developer = null) { |
|
77 | } |
||
78 |
The
EntityManager
might become unusable for example if a transaction is rolled back and it gets closed. Let’s assume that somewhere in your application, or in a third-party library, there is code such as the following:If that code throws an exception and the
EntityManager
is closed. Any other code which depends on the same instance of theEntityManager
during this request will fail.On the other hand, if you instead inject the
ManagerRegistry
, thegetManager()
method guarantees that you will always get a usable manager instance.