File tree 3 files changed +34
-16
lines changed
3 files changed +34
-16
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 16
16
17
17
class ConfigProvider
18
18
{
19
+ public const ADAPTER_PLUGIN_MANAGER_CONFIGURATION_KEY = 'storage_adapters ' ;
20
+
19
21
/**
20
22
* Return default configuration for laminas-cache.
21
23
*
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
+ declare (strict_types=1 );
4
+
3
5
namespace Laminas \Cache \Service ;
4
6
7
+ use Laminas \Cache \ConfigProvider ;
5
8
use Laminas \Cache \Storage \AdapterPluginManager ;
9
+ use Laminas \ServiceManager \ServiceManager ;
6
10
use Psr \Container \ContainerInterface ;
7
11
12
+ use function is_array ;
13
+
14
+ /**
15
+ * @psalm-import-type ServiceManagerConfiguration from ServiceManager
16
+ */
8
17
final class StorageAdapterPluginManagerFactory
9
18
{
10
19
public function __invoke (ContainerInterface $ container ): AdapterPluginManager
11
20
{
12
- return new AdapterPluginManager ($ container );
21
+ $ pluginManager = new AdapterPluginManager ($ container );
22
+
23
+ // If we do not have a config service, nothing more to do
24
+ if (! $ container ->has ('config ' )) {
25
+ return $ pluginManager ;
26
+ }
27
+
28
+ $ config = $ container ->get ('config ' );
29
+
30
+ // If we do not have a configuration, nothing more to do
31
+ if (
32
+ ! isset ($ config [ConfigProvider::ADAPTER_PLUGIN_MANAGER_CONFIGURATION_KEY ])
33
+ || ! is_array ($ config [ConfigProvider::ADAPTER_PLUGIN_MANAGER_CONFIGURATION_KEY ])
34
+ ) {
35
+ return $ pluginManager ;
36
+ }
37
+
38
+ // Wire service configuration
39
+ /** @var ServiceManagerConfiguration $config */
40
+ $ config = $ config [ConfigProvider::ADAPTER_PLUGIN_MANAGER_CONFIGURATION_KEY ];
41
+ $ pluginManager ->configure ($ config );
42
+
43
+ return $ pluginManager ;
13
44
}
14
45
}
You can’t perform that action at this time.
0 commit comments