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
|
|
|
use Zend\Log\Logger; |
15
|
|
|
use Zend\Log\Writer\Noop; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Class EntryIdResolverFactory |
19
|
|
|
* |
20
|
|
|
* @package OldTown\Workflow\ZF2\Toolkit\WorkflowRunParams |
21
|
|
|
*/ |
22
|
|
|
class EntryIdResolverFactory implements FactoryInterface |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* @param ServiceLocatorInterface $serviceLocator |
26
|
|
|
* |
27
|
|
|
* @return EntryIdResolver |
28
|
|
|
* @throws \Zend\ServiceManager\Exception\ServiceNotFoundException |
29
|
|
|
* @throws \Zend\ServiceManager\Exception\ServiceNotCreatedException |
30
|
|
|
* @throws \Zend\ServiceManager\Exception\RuntimeException |
31
|
|
|
* @throws \Zend\Log\Exception\InvalidArgumentException |
32
|
|
|
*/ |
33
|
|
|
public function createService(ServiceLocatorInterface $serviceLocator) |
34
|
|
|
{ |
35
|
|
|
/** @var WorkflowServiceManager $wfServiceManager */ |
36
|
|
|
$wfServiceManager = $serviceLocator->get(WorkflowServiceManager::class); |
37
|
|
|
|
38
|
|
|
/** @var EntryToObjectsService $entryToObjectsService */ |
39
|
|
|
$entryToObjectsService = $wfServiceManager->get(EntryToObjectsService::class); |
40
|
|
|
$moduleOptions = $serviceLocator->get(ModuleOptions::class); |
41
|
|
|
|
42
|
|
|
/** @var Application $app */ |
43
|
|
|
$app = $serviceLocator->get('Application'); |
44
|
|
|
$mvcEvent = $app->getMvcEvent(); |
45
|
|
|
|
46
|
|
|
$logName = $moduleOptions->getLogName(); |
47
|
|
|
if (null === $logName) { |
48
|
|
|
$log = new Logger(); |
49
|
|
|
$writer = new Noop(); |
50
|
|
|
$log->addWriter($writer); |
51
|
|
|
} else { |
52
|
|
|
$log = $serviceLocator->get($logName); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
$options = [ |
56
|
|
|
'entryToObjectsService' => $entryToObjectsService, |
57
|
|
|
'moduleOptions' => $moduleOptions, |
58
|
|
|
'mvcEvent' => $mvcEvent, |
59
|
|
|
'log' => $log |
60
|
|
|
]; |
61
|
|
|
|
62
|
|
|
return new EntryIdResolver($options); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|