11
11
12
12
use Zend \Cache \Exception ;
13
13
use Zend \ServiceManager \AbstractPluginManager ;
14
+ use Zend \ServiceManager \Factory \InvokableFactory ;
14
15
15
16
/**
16
17
* Plugin manager implementation for cache storage adapters
21
22
*/
22
23
class AdapterPluginManager extends AbstractPluginManager
23
24
{
24
- /**
25
- * Default set of adapters
26
- *
27
- * @var array
28
- */
29
- protected $ invokableClasses = [
30
- 'apc ' => 'Zend\Cache\Storage\Adapter\Apc ' ,
31
- 'blackhole ' => 'Zend\Cache\Storage\Adapter\BlackHole ' ,
32
- 'dba ' => 'Zend\Cache\Storage\Adapter\Dba ' ,
33
- 'filesystem ' => 'Zend\Cache\Storage\Adapter\Filesystem ' ,
34
- 'memcache ' => 'Zend\Cache\Storage\Adapter\Memcache ' ,
35
- 'memcached ' => 'Zend\Cache\Storage\Adapter\Memcached ' ,
36
- 'memory ' => 'Zend\Cache\Storage\Adapter\Memory ' ,
37
- 'mongodb ' => 'Zend\Cache\Storage\Adapter\MongoDb ' ,
38
- 'redis ' => 'Zend\Cache\Storage\Adapter\Redis ' ,
39
- 'session ' => 'Zend\Cache\Storage\Adapter\Session ' ,
40
- 'xcache ' => 'Zend\Cache\Storage\Adapter\XCache ' ,
41
- 'wincache ' => 'Zend\Cache\Storage\Adapter\WinCache ' ,
42
- 'zendserverdisk ' => 'Zend\Cache\Storage\Adapter\ZendServerDisk ' ,
43
- 'zendservershm ' => 'Zend\Cache\Storage\Adapter\ZendServerShm ' ,
25
+ protected $ aliases = [
26
+ 'apc ' => Adapter \Apc::class,
27
+ 'Apc ' => Adapter \Apc::class,
28
+ 'blackhole ' => Adapter \BlackHole::class,
29
+ 'BlackHole ' => Adapter \BlackHole::class,
30
+ 'dba ' => Adapter \Dba::class,
31
+ 'Dba ' => Adapter \Dba::class,
32
+ 'filesystem ' => Adapter \Filesystem::class,
33
+ 'Filesystem ' => Adapter \Filesystem::class,
34
+ 'memcache ' => Adapter \Memcache::class,
35
+ 'Memcache ' => Adapter \Memcache::class,
36
+ 'memcached ' => Adapter \Memcached::class,
37
+ 'Memcached ' => Adapter \Memcached::class,
38
+ 'memory ' => Adapter \Memory::class,
39
+ 'Memory ' => Adapter \Memory::class,
40
+ 'mongodb ' => Adapter \MongoDb::class,
41
+ 'MongoDb ' => Adapter \MongoDb::class,
42
+ 'redis ' => Adapter \Redis::class,
43
+ 'Redis ' => Adapter \Redis::class,
44
+ 'session ' => Adapter \Session::class,
45
+ 'Session ' => Adapter \Session::class,
46
+ 'xcache ' => Adapter \XCache::class,
47
+ 'XCache ' => Adapter \XCache::class,
48
+ 'wincache ' => Adapter \WinCache::class,
49
+ 'WinCache ' => Adapter \WinCache::class,
50
+ 'zendserverdisk ' => Adapter \ZendServerDisk::class,
51
+ 'ZendServerDisk ' => Adapter \ZendServerDisk::class,
52
+ 'zendservershm ' => Adapter \ZendServerShm::class,
53
+ 'ZendServerShm ' => Adapter \ZendServerShm::class
54
+ ];
55
+
56
+ protected $ factories = [
57
+ Adapter \Apc::class => InvokableFactory::class,
58
+ Adapter \BlackHole::class => InvokableFactory::class,
59
+ Adapter \Dba::class => InvokableFactory::class,
60
+ Adapter \Filesystem::class => InvokableFactory::class,
61
+ Adapter \Memcache::class => InvokableFactory::class,
62
+ Adapter \Memcached::class => InvokableFactory::class,
63
+ Adapter \Memory::class => InvokableFactory::class,
64
+ Adapter \MongoDb::class => InvokableFactory::class,
65
+ Adapter \Redis::class => InvokableFactory::class,
66
+ Adapter \Session::class => InvokableFactory::class,
67
+ Adapter \XCache::class => InvokableFactory::class,
68
+ Adapter \WinCache::class => InvokableFactory::class,
69
+ Adapter \ZendServerDisk::class => InvokableFactory::class,
70
+ Adapter \ZendServerShm::class => InvokableFactory::class
44
71
];
45
72
46
73
/**
@@ -51,25 +78,7 @@ class AdapterPluginManager extends AbstractPluginManager
51
78
protected $ shareByDefault = false ;
52
79
53
80
/**
54
- * Validate the plugin
55
- *
56
- * Checks that the adapter loaded is an instance of StorageInterface.
57
- *
58
- * @param mixed $plugin
59
- * @return void
60
- * @throws Exception\RuntimeException if invalid
81
+ * @var string
61
82
*/
62
- public function validatePlugin ($ plugin )
63
- {
64
- if ($ plugin instanceof StorageInterface) {
65
- // we're okay
66
- return ;
67
- }
68
-
69
- throw new Exception \RuntimeException (sprintf (
70
- 'Plugin of type %s is invalid; must implement %s\StorageInterface ' ,
71
- (is_object ($ plugin ) ? get_class ($ plugin ) : gettype ($ plugin )),
72
- __NAMESPACE__
73
- ));
74
- }
83
+ protected $ instanceOf = StorageInterface::class;
75
84
}
0 commit comments