1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/**
* @see https://github.com/zendframework/zend-cache for the canonical source repository
* @copyright Copyright (c) 2018 Zend Technologies USA Inc. (http://www.zend.com)
* @license https://github.com/zendframework/zend-cache/blob/master/LICENSE.md New BSD License
*/
namespace Zend\Cache\PatternPluginManager;
use Zend\Cache\Pattern;
use Zend\ServiceManager\AbstractPluginManager;
use Zend\ServiceManager\Factory\InvokableFactory;
/**
* zend-servicemanager v2-compatible plugin manager implementation for cache pattern adapters.
*
* Enforces that retrieved adapters are instances of
* Pattern\PatternInterface. Additionally, it registers a number of default
* patterns available.
*/
class PatternPluginManagerV2Polyfill extends AbstractPluginManager
{
use PatternPluginManagerTrait;
protected $aliases = [
'callback' => Pattern\CallbackCache::class,
'Callback' => Pattern\CallbackCache::class,
'capture' => Pattern\CaptureCache::class,
'Capture' => Pattern\CaptureCache::class,
'class' => Pattern\ClassCache::class,
'Class' => Pattern\ClassCache::class,
'object' => Pattern\ObjectCache::class,
'Object' => Pattern\ObjectCache::class,
'output' => Pattern\OutputCache::class,
'Output' => Pattern\OutputCache::class,
];
protected $factories = [
Pattern\CallbackCache::class => InvokableFactory::class,
Pattern\CaptureCache::class => InvokableFactory::class,
Pattern\ClassCache::class => InvokableFactory::class,
Pattern\ObjectCache::class => InvokableFactory::class,
Pattern\OutputCache::class => InvokableFactory::class,
// v2 normalized FQCNs
'zendcachepatterncallbackcache' => InvokableFactory::class,
'zendcachepatterncapturecache' => InvokableFactory::class,
'zendcachepatternclasscache' => InvokableFactory::class,
'zendcachepatternobjectcache' => InvokableFactory::class,
'zendcachepatternoutputcache' => InvokableFactory::class,
];
/**
* Don't share by default
*
* @var bool
*/
protected $shareByDefault = false;
/**
* Don't share by default
*
* @var bool
*/
protected $sharedByDefault = false;
/**
* @var string
*/
protected $instanceOf = Pattern\PatternInterface::class;
/**
* Override get to inject options as PatternOptions instance.
*
* {@inheritDoc}
*/
public function get($plugin, $options = [], $usePeeringServiceManagers = true)
{
if (empty($options)) {
return parent::get($plugin, [], $usePeeringServiceManagers);
}
$plugin = parent::get($plugin, [], $usePeeringServiceManagers);
$plugin->setOptions(new Pattern\PatternOptions($options));
return $plugin;
}
}