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