1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @link https://github.com/nnx-framework/entry-name-resolver |
4
|
|
|
* @author Malofeykin Andrey <[email protected]> |
5
|
|
|
*/ |
6
|
|
|
namespace Nnx\EntryNameResolver; |
7
|
|
|
|
8
|
|
|
use Nnx\ModuleOptions\ModuleOptionsPluginManagerInterface; |
9
|
|
|
use Zend\ServiceManager\AbstractPluginManager; |
10
|
|
|
use Zend\ServiceManager\FactoryInterface; |
11
|
|
|
use Zend\ServiceManager\MutableCreationOptionsInterface; |
12
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
13
|
|
|
use Zend\ServiceManager\MutableCreationOptionsTrait; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Class ResolverByMapFactory |
17
|
|
|
* |
18
|
|
|
* @package Nnx\EntryNameResolver\EntryNameResolver |
19
|
|
|
*/ |
20
|
|
|
class ResolverByModuleContextMapFactory implements FactoryInterface, MutableCreationOptionsInterface |
21
|
|
|
{ |
22
|
|
|
use MutableCreationOptionsTrait; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @inheritdoc |
26
|
|
|
* |
27
|
|
|
* @param ServiceLocatorInterface $serviceLocator |
28
|
|
|
* |
29
|
|
|
* @return ResolverByModuleContextMap |
30
|
|
|
* |
31
|
|
|
* @throws \Zend\ServiceManager\Exception\ServiceNotFoundException |
32
|
|
|
*/ |
33
|
|
|
public function createService(ServiceLocatorInterface $serviceLocator) |
34
|
|
|
{ |
35
|
|
|
$appServiceLocator = $serviceLocator; |
36
|
|
|
if ($serviceLocator instanceof AbstractPluginManager) { |
37
|
|
|
$appServiceLocator = $serviceLocator->getServiceLocator(); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** @var ModuleOptionsPluginManagerInterface $moduleOptionsPluginManager */ |
41
|
|
|
$moduleOptionsPluginManager = $appServiceLocator->get(ModuleOptionsPluginManagerInterface::class); |
42
|
|
|
|
43
|
|
|
|
44
|
|
|
$creationOptions = $this->getCreationOptions(); |
45
|
|
|
$options = is_array($creationOptions) ? $creationOptions : []; |
46
|
|
|
|
47
|
|
|
$contextMap = array_key_exists('contextMap', $options) ? $options['contextMap'] : []; |
48
|
|
|
|
49
|
|
|
$resolverByModuleContextMap = new ResolverByModuleContextMap($moduleOptionsPluginManager); |
50
|
|
|
$resolverByModuleContextMap->setContextMap($contextMap); |
51
|
|
|
|
52
|
|
|
return $resolverByModuleContextMap; |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|