2
2
3
3
namespace Drupal \os2web_datalookup \Plugin ;
4
4
5
+ use Drupal \Core \Config \ConfigFactoryInterface ;
5
6
use Drupal \Core \Plugin \DefaultPluginManager ;
6
7
use Drupal \Core \Cache \CacheBackendInterface ;
7
8
use Drupal \Core \Extension \ModuleHandlerInterface ;
9
+ use Drupal \os2web_datalookup \Form \DataLookupPluginSettingsForm ;
8
10
9
11
/**
10
12
* DataLookupManager plugin manager.
15
17
*/
16
18
class DataLookupManager extends DefaultPluginManager {
17
19
20
+ /**
21
+ * The config factory.
22
+ *
23
+ * @var \Drupal\Core\Config\ConfigFactoryInterface
24
+ */
25
+ protected $ configFactory ;
26
+
18
27
/**
19
28
* Constructs an DataLookupManager object.
20
29
*
@@ -25,8 +34,10 @@ class DataLookupManager extends DefaultPluginManager {
25
34
* Cache backend instance to use.
26
35
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
27
36
* The module handler to invoke the alter hook with.
37
+ * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
38
+ * The config factory.
28
39
*/
29
- public function __construct (\Traversable $ namespaces , CacheBackendInterface $ cache_backend , ModuleHandlerInterface $ module_handler ) {
40
+ public function __construct (\Traversable $ namespaces , CacheBackendInterface $ cache_backend , ModuleHandlerInterface $ module_handler, ConfigFactoryInterface $ config_factory ) {
30
41
parent ::__construct (
31
42
'Plugin/os2web/DataLookup ' ,
32
43
$ namespaces ,
@@ -36,6 +47,17 @@ public function __construct(\Traversable $namespaces, CacheBackendInterface $cac
36
47
37
48
$ this ->alterInfo ('os2web_datalookup_info ' );
38
49
$ this ->setCacheBackend ($ cache_backend , 'os2web_datalookup ' );
50
+ $ this ->configFactory = $ config_factory ;
51
+ }
52
+
53
+ /**
54
+ * {@inheritdoc}
55
+ */
56
+ public function createInstance ($ plugin_id , array $ configuration = []) {
57
+ if (empty ($ configuration )) {
58
+ $ configuration = $ this ->configFactory ->get (DataLookupPluginSettingsForm::getConfigName () . '. ' . $ plugin_id )->get ();
59
+ }
60
+ return parent ::createInstance ($ plugin_id , $ configuration );
39
61
}
40
62
41
63
}
0 commit comments