2
2
3
3
namespace Drupal \os2web_datalookup \Plugin \os2web \DataLookup ;
4
4
5
+ use Drupal \Core \File \FileExists ;
5
6
use Drupal \Core \File \FileSystem ;
6
7
use Drupal \Core \Form \FormStateInterface ;
7
8
use Drupal \Core \Plugin \ContainerFactoryPluginInterface ;
22
23
* @see plugin_api
23
24
*/
24
25
abstract class DataLookupBase extends PluginBase implements DataLookupInterface, ContainerFactoryPluginInterface {
25
- protected const PROVIDER_TYPE_FORM = 'form ' ;
26
- protected const PROVIDER_TYPE_KEY = 'key ' ;
26
+ protected const string PROVIDER_TYPE_FORM = 'form ' ;
27
+ protected const string PROVIDER_TYPE_KEY = 'key ' ;
27
28
28
29
/**
29
30
* Local certificate path.
30
31
*
31
- * Used to temporarily store a certificate in a file just before calling a webservice.
32
- * For security purposes, the file will be removed right after the webservice calls completes.
32
+ * Used to temporarily store a certificate in a file just before calling a
33
+ * webservice.
34
+ * For security purposes, the file will be removed right after the webservice
35
+ * call completes (even unsuccessfully).
33
36
*
34
37
* @var string
35
38
*/
@@ -42,34 +45,27 @@ abstract class DataLookupBase extends PluginBase implements DataLookupInterface,
42
45
*/
43
46
protected bool $ isReady = TRUE ;
44
47
45
- /**
46
- * Audit logger.
47
- *
48
- * @var \Drupal\os2web_audit\Service\Logger
49
- */
50
- protected Logger $ auditLogger ;
51
-
52
48
/**
53
49
* {@inheritdoc}
54
50
*/
55
51
public function __construct (
56
52
array $ configuration ,
57
53
$ plugin_id ,
58
54
$ plugin_definition ,
59
- Logger $ auditLogger ,
55
+ protected Logger $ auditLogger ,
60
56
protected KeyRepositoryInterface $ keyRepository ,
61
57
protected FileSystem $ fileSystem ,
62
58
) {
63
59
parent ::__construct ($ configuration , $ plugin_id , $ plugin_definition );
64
- $ this ->auditLogger = $ auditLogger ;
65
60
$ this ->setConfiguration ($ configuration );
66
- $ this ->init ();
67
61
}
68
62
69
63
/**
70
- *
64
+ * {@inheritdoc}
71
65
*/
72
66
public static function create (ContainerInterface $ container , array $ configuration , $ plugin_id , $ plugin_definition ) {
67
+ /** @var \Drupal\os2web_audit\Service\Logger $auditLogger */
68
+ $ auditLogger = $ container ->get ('os2web_audit.logger ' );
73
69
/** @var \Drupal\key\KeyRepositoryInterface $keyRepository */
74
70
$ keyRepository = $ container ->get ('key.repository ' );
75
71
/** @var \Drupal\Core\File\FileSystem $fileSystem */
@@ -79,29 +75,12 @@ public static function create(ContainerInterface $container, array $configuratio
79
75
$ configuration ,
80
76
$ plugin_id ,
81
77
$ plugin_definition ,
78
+ $ auditLogger ,
82
79
$ keyRepository ,
83
80
$ fileSystem
84
81
);
85
82
}
86
83
87
- /**
88
- * Plugin init method.
89
- */
90
- protected function init () {
91
- }
92
-
93
- /**
94
- * {@inheritdoc}
95
- */
96
- public static function create (ContainerInterface $ container , array $ configuration , $ plugin_id , $ plugin_definition ) {
97
- return new static (
98
- $ configuration ,
99
- $ plugin_id ,
100
- $ plugin_definition ,
101
- $ container ->get ('os2web_audit.logger ' ),
102
- );
103
- }
104
-
105
84
/**
106
85
* {@inheritdoc}
107
86
*/
@@ -194,7 +173,7 @@ protected function writeCertificateToFile(): string {
194
173
// Write certificate to local_cert location.
195
174
$ certificate = $ this ->getCertificate ();
196
175
$ localCertPath = $ this ->localCertPath ;
197
- $ result = $ this ->fileSystem ->saveData ($ certificate , $ localCertPath , FileSystem:: EXISTS_REPLACE );
176
+ $ result = $ this ->fileSystem ->saveData ($ certificate , $ localCertPath , FileExists::Replace );
198
177
if (!$ result ) {
199
178
return new RuntimeException (sprintf ('Error writing certificate to temporary file %s ' , $ localCertPath ));
200
179
}
0 commit comments