composer package updates
[openemr.git] / vendor / zendframework / zend-cache / src / Storage / AdapterPluginManager.php
blob98b73f35dee6e6f782925b4f78c5859c1931c2d8
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2018 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Cache\Storage;
12 use Zend\Cache\Exception\RuntimeException;
13 use Zend\ServiceManager\AbstractPluginManager;
14 use Zend\ServiceManager\Exception\InvalidServiceException;
15 use Zend\ServiceManager\Factory\InvokableFactory;
17 /**
18 * Plugin manager implementation for cache storage adapters
20 * Enforces that adapters retrieved are instances of
21 * StorageInterface. Additionally, it registers a number of default
22 * adapters available.
24 class AdapterPluginManager extends AbstractPluginManager
26 protected $aliases = [
27 'apc' => Adapter\Apc::class,
28 'Apc' => Adapter\Apc::class,
29 'APC' => Adapter\Apc::class,
30 'apcu' => Adapter\Apcu::class,
31 'ApcU' => Adapter\Apcu::class,
32 'Apcu' => Adapter\Apcu::class,
33 'APCu' => Adapter\Apcu::class,
34 'black_hole' => Adapter\BlackHole::class,
35 'blackhole' => Adapter\BlackHole::class,
36 'blackHole' => Adapter\BlackHole::class,
37 'BlackHole' => Adapter\BlackHole::class,
38 'dba' => Adapter\Dba::class,
39 'Dba' => Adapter\Dba::class,
40 'DBA' => Adapter\Dba::class,
41 'ext_mongo_db' => Adapter\ExtMongoDb::class,
42 'extmongodb' => Adapter\ExtMongoDb::class,
43 'ExtMongoDb' => Adapter\ExtMongoDb::class,
44 'ExtMongoDB' => Adapter\ExtMongoDb::class,
45 'extMongoDb' => Adapter\ExtMongoDb::class,
46 'extMongoDB' => Adapter\ExtMongoDb::class,
47 'filesystem' => Adapter\Filesystem::class,
48 'Filesystem' => Adapter\Filesystem::class,
49 'memcache' => Adapter\Memcache::class,
50 'Memcache' => Adapter\Memcache::class,
51 'memcached' => Adapter\Memcached::class,
52 'Memcached' => Adapter\Memcached::class,
53 'memory' => Adapter\Memory::class,
54 'Memory' => Adapter\Memory::class,
55 'mongo_db' => Adapter\MongoDb::class,
56 'mongodb' => Adapter\MongoDb::class,
57 'MongoDb' => Adapter\MongoDb::class,
58 'MongoDB' => Adapter\MongoDb::class,
59 'mongoDb' => Adapter\MongoDb::class,
60 'mongoDB' => Adapter\MongoDb::class,
61 'redis' => Adapter\Redis::class,
62 'Redis' => Adapter\Redis::class,
63 'session' => Adapter\Session::class,
64 'Session' => Adapter\Session::class,
65 'xcache' => Adapter\XCache::class,
66 'xCache' => Adapter\XCache::class,
67 'Xcache' => Adapter\XCache::class,
68 'XCache' => Adapter\XCache::class,
69 'win_cache' => Adapter\WinCache::class,
70 'wincache' => Adapter\WinCache::class,
71 'winCache' => Adapter\WinCache::class,
72 'WinCache' => Adapter\WinCache::class,
73 'zend_server_disk' => Adapter\ZendServerDisk::class,
74 'zendserverdisk' => Adapter\ZendServerDisk::class,
75 'zendServerDisk' => Adapter\ZendServerDisk::class,
76 'ZendServerDisk' => Adapter\ZendServerDisk::class,
77 'zend_server_shm' => Adapter\ZendServerShm::class,
78 'zendservershm' => Adapter\ZendServerShm::class,
79 'zendServerShm' => Adapter\ZendServerShm::class,
80 'zendServerSHM' => Adapter\ZendServerShm::class,
81 'ZendServerShm' => Adapter\ZendServerShm::class,
82 'ZendServerSHM' => Adapter\ZendServerShm::class,
85 protected $factories = [
86 Adapter\Apc::class => InvokableFactory::class,
87 Adapter\Apcu::class => InvokableFactory::class,
88 Adapter\BlackHole::class => InvokableFactory::class,
89 Adapter\Dba::class => InvokableFactory::class,
90 Adapter\ExtMongoDb::class => InvokableFactory::class,
91 Adapter\Filesystem::class => InvokableFactory::class,
92 Adapter\Memcache::class => InvokableFactory::class,
93 Adapter\Memcached::class => InvokableFactory::class,
94 Adapter\Memory::class => InvokableFactory::class,
95 Adapter\MongoDb::class => InvokableFactory::class,
96 Adapter\Redis::class => InvokableFactory::class,
97 Adapter\Session::class => InvokableFactory::class,
98 Adapter\WinCache::class => InvokableFactory::class,
99 Adapter\XCache::class => InvokableFactory::class,
100 Adapter\ZendServerDisk::class => InvokableFactory::class,
101 Adapter\ZendServerShm::class => InvokableFactory::class,
103 // v2 normalized FQCNs
104 'zendcachestorageadapterapc' => InvokableFactory::class,
105 'zendcachestorageadapterapcu' => InvokableFactory::class,
106 'zendcachestorageadapterblackhole' => InvokableFactory::class,
107 'zendcachestorageadapterdba' => InvokableFactory::class,
108 'zendcachestorageadapterextmongodb' => InvokableFactory::class,
109 'zendcachestorageadapterfilesystem' => InvokableFactory::class,
110 'zendcachestorageadaptermemcache' => InvokableFactory::class,
111 'zendcachestorageadaptermemcached' => InvokableFactory::class,
112 'zendcachestorageadaptermemory' => InvokableFactory::class,
113 'zendcachestorageadaptermongodb' => InvokableFactory::class,
114 'zendcachestorageadapterredis' => InvokableFactory::class,
115 'zendcachestorageadaptersession' => InvokableFactory::class,
116 'zendcachestorageadapterwincache' => InvokableFactory::class,
117 'zendcachestorageadapterxcache' => InvokableFactory::class,
118 'zendcachestorageadapterzendserverdisk' => InvokableFactory::class,
119 'zendcachestorageadapterzendservershm' => InvokableFactory::class,
123 * Do not share by default (v3)
125 * @var array
127 protected $sharedByDefault = false;
130 * Don't share by default (v2)
132 * @var boolean
134 protected $shareByDefault = false;
137 * @var string
139 protected $instanceOf = StorageInterface::class;
142 * Validate the plugin is of the expected type (v3).
144 * Validates against `$instanceOf`.
146 * @param mixed $instance
147 * @throws InvalidServiceException
149 public function validate($instance)
151 if (! $instance instanceof $this->instanceOf) {
152 throw new InvalidServiceException(sprintf(
153 '%s can only create instances of %s; %s is invalid',
154 get_class($this),
155 $this->instanceOf,
156 (is_object($instance) ? get_class($instance) : gettype($instance))
162 * Validate the plugin is of the expected type (v2).
164 * Proxies to `validate()`.
166 * @param mixed $instance
167 * @throws InvalidServiceException
169 public function validatePlugin($instance)
171 try {
172 $this->validate($instance);
173 } catch (InvalidServiceException $e) {
174 throw new RuntimeException($e->getMessage(), $e->getCode(), $e);