|
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 Interop\Container\ContainerInterface; |
|
9
|
|
|
use Zend\ServiceManager\AbstractPluginManager; |
|
10
|
|
|
use Zend\ServiceManager\ConfigInterface; |
|
11
|
|
|
use Zend\ServiceManager\Exception; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Class EntryNameResolverManager |
|
15
|
|
|
* |
|
16
|
|
|
* @package Nnx\EntryNameResolver\EntryNameResolver |
|
17
|
|
|
* |
|
18
|
|
|
* @method EntryNameResolverInterface get($id) |
|
19
|
|
|
*/ |
|
20
|
|
|
class EntryNameResolverManager extends AbstractPluginManager implements ContainerInterface |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* Имя секции в конфиги приложения отвечающей за настройки менеджера |
|
24
|
|
|
* |
|
25
|
|
|
* @var string |
|
26
|
|
|
*/ |
|
27
|
|
|
const CONFIG_KEY = 'nnx_container_entry_name_resolver'; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* EntryNameResolverManager constructor. |
|
31
|
|
|
* |
|
32
|
|
|
* @param null|ConfigInterface $configuration |
|
33
|
|
|
* |
|
34
|
|
|
* @throws \Zend\ServiceManager\Exception\RuntimeException |
|
35
|
|
|
*/ |
|
36
|
|
|
public function __construct(ConfigInterface $configuration = null) |
|
37
|
|
|
{ |
|
38
|
|
|
parent::__construct($configuration); |
|
39
|
|
|
$this->setShareByDefault(false); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* {@inheritDoc} |
|
45
|
|
|
* |
|
46
|
|
|
* @throws Exception\RuntimeException |
|
47
|
|
|
*/ |
|
48
|
|
|
public function validatePlugin($plugin) |
|
49
|
|
|
{ |
|
50
|
|
|
if ($plugin instanceof EntryNameResolverInterface) { |
|
51
|
|
|
return; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
throw new Exception\RuntimeException(sprintf( |
|
55
|
|
|
'Plugin of type %s is invalid; must implement %s', |
|
56
|
|
|
(is_object($plugin) ? get_class($plugin) : gettype($plugin)), |
|
57
|
|
|
EntryNameResolverInterface::class |
|
58
|
|
|
)); |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|