1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @link https://github.com/old-town/workflow-zf2-toolkit |
4
|
|
|
* @author Malofeykin Andrey <[email protected]> |
5
|
|
|
*/ |
6
|
|
|
namespace OldTown\Workflow\ZF2\Toolkit\WorkflowRunParams; |
7
|
|
|
|
8
|
|
|
use Zend\Mvc\Application; |
9
|
|
|
use Zend\ServiceManager\FactoryInterface; |
10
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
11
|
|
|
use OldTown\Workflow\ZF2\Service\Service\Manager as WorkflowServiceManager; |
12
|
|
|
use OldTown\Workflow\ZF2\Toolkit\EntryToObjects\EntryToObjectsService; |
13
|
|
|
use OldTown\Workflow\ZF2\Toolkit\Options\ModuleOptions; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Class EntryIdResolverFactory |
17
|
|
|
* |
18
|
|
|
* @package OldTown\Workflow\ZF2\Toolkit\WorkflowRunParams |
19
|
|
|
*/ |
20
|
|
View Code Duplication |
class EntryIdResolverFactory implements FactoryInterface |
|
|
|
|
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* @param ServiceLocatorInterface $serviceLocator |
24
|
|
|
* |
25
|
|
|
* @return EntryIdResolver |
26
|
|
|
* @throws \Zend\ServiceManager\Exception\ServiceNotFoundException |
27
|
|
|
* @throws \Zend\ServiceManager\Exception\ServiceNotCreatedException |
28
|
|
|
* @throws \Zend\ServiceManager\Exception\RuntimeException |
29
|
|
|
*/ |
30
|
|
|
public function createService(ServiceLocatorInterface $serviceLocator) |
31
|
|
|
{ |
32
|
|
|
/** @var WorkflowServiceManager $wfServiceManager */ |
33
|
|
|
$wfServiceManager = $serviceLocator->get(WorkflowServiceManager::class); |
34
|
|
|
|
35
|
|
|
/** @var EntryToObjectsService $entryToObjectsService */ |
36
|
|
|
$entryToObjectsService = $wfServiceManager->get(EntryToObjectsService::class); |
37
|
|
|
$moduleOptions = $serviceLocator->get(ModuleOptions::class); |
38
|
|
|
|
39
|
|
|
/** @var Application $app */ |
40
|
|
|
$app = $serviceLocator->get('Application'); |
41
|
|
|
$mvcEvent = $app->getMvcEvent(); |
42
|
|
|
|
43
|
|
|
$options = [ |
44
|
|
|
'entryToObjectsService' => $entryToObjectsService, |
45
|
|
|
'moduleOptions' => $moduleOptions, |
46
|
|
|
'mvcEvent' => $mvcEvent |
47
|
|
|
]; |
48
|
|
|
|
49
|
|
|
return new EntryIdResolver($options); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.