3 * @see https://github.com/zendframework/zend-cache for the canonical source repository
4 * @copyright Copyright (c) 2018 Zend Technologies USA Inc. (http://www.zend.com)
5 * @license https://github.com/zendframework/zend-cache/blob/master/LICENSE.md New BSD License
8 namespace Zend\Cache\PatternPluginManager
;
10 use Zend\Cache\Pattern
;
11 use Zend\ServiceManager\AbstractPluginManager
;
12 use Zend\ServiceManager\Factory\InvokableFactory
;
15 * zend-servicemanager v2-compatible plugin manager implementation for cache pattern adapters.
17 * Enforces that retrieved adapters are instances of
18 * Pattern\PatternInterface. Additionally, it registers a number of default
21 class PatternPluginManagerV2Polyfill
extends AbstractPluginManager
23 use PatternPluginManagerTrait
;
25 protected $aliases = [
26 'callback' => Pattern\CallbackCache
::class,
27 'Callback' => Pattern\CallbackCache
::class,
28 'capture' => Pattern\CaptureCache
::class,
29 'Capture' => Pattern\CaptureCache
::class,
30 'class' => Pattern\ClassCache
::class,
31 'Class' => Pattern\ClassCache
::class,
32 'object' => Pattern\ObjectCache
::class,
33 'Object' => Pattern\ObjectCache
::class,
34 'output' => Pattern\OutputCache
::class,
35 'Output' => Pattern\OutputCache
::class,
38 protected $factories = [
39 Pattern\CallbackCache
::class => InvokableFactory
::class,
40 Pattern\CaptureCache
::class => InvokableFactory
::class,
41 Pattern\ClassCache
::class => InvokableFactory
::class,
42 Pattern\ObjectCache
::class => InvokableFactory
::class,
43 Pattern\OutputCache
::class => InvokableFactory
::class,
45 // v2 normalized FQCNs
46 'zendcachepatterncallbackcache' => InvokableFactory
::class,
47 'zendcachepatterncapturecache' => InvokableFactory
::class,
48 'zendcachepatternclasscache' => InvokableFactory
::class,
49 'zendcachepatternobjectcache' => InvokableFactory
::class,
50 'zendcachepatternoutputcache' => InvokableFactory
::class,
54 * Don't share by default
58 protected $shareByDefault = false;
61 * Don't share by default
65 protected $sharedByDefault = false;
70 protected $instanceOf = Pattern\PatternInterface
::class;
73 * Override get to inject options as PatternOptions instance.
77 public function get($plugin, $options = [], $usePeeringServiceManagers = true)
79 if (empty($options)) {
80 return parent
::get($plugin, [], $usePeeringServiceManagers);
83 $plugin = parent
::get($plugin, [], $usePeeringServiceManagers);
84 $plugin->setOptions(new Pattern\
PatternOptions($options));