@@ -73,7 +73,7 @@ public function __construct(Manager $manager, LoggerInterface $logger)
73
73
}
74
74
75
75
/**
76
- * Creates a new installer instance with a Pdp\Cache.
76
+ * Creates a new instance with a Pdp\Cache object and the cURL HTTP client .
77
77
* @param LoggerInterface $logger
78
78
* @param string $cacheDir
79
79
*/
@@ -82,6 +82,10 @@ public static function createFromCacheDir(LoggerInterface $logger, string $cache
82
82
return new self (new Manager (new Cache ($ cacheDir ), new CurlHttpClient ()), $ logger );
83
83
}
84
84
85
+ /**
86
+ * Refresh the locale cache.
87
+ * @param array $context
88
+ */
85
89
public function refresh (array $ context = []): bool
86
90
{
87
91
$ context = filter_var_array (array_replace (self ::DEFAULT_CONTEXT , $ context ), [
@@ -110,10 +114,7 @@ public function refresh(array $context = []): bool
110
114
111
115
/**
112
116
* Refreshes the cache.
113
- *
114
117
* @param array $arguments
115
- *
116
- * @throws PsrCacheException
117
118
*/
118
119
private function execute (array $ arguments = []): bool
119
120
{
@@ -157,8 +158,7 @@ private function execute(array $arguments = []): bool
157
158
158
159
/**
159
160
* Script to update the local cache using composer hook.
160
- *
161
- * @param Event $event
161
+ * @param null|Event $event
162
162
*/
163
163
public static function updateLocalCache (Event $ event = null )
164
164
{
@@ -181,6 +181,7 @@ public static function updateLocalCache(Event $event = null)
181
181
182
182
require $ vendor .'/autoload.php ' ;
183
183
184
+ $ logger = new Logger ();
184
185
$ arguments = [
185
186
self ::CACHE_DIR_KEY => '' ,
186
187
self ::REFRESH_PSL_KEY => false ,
@@ -189,17 +190,19 @@ public static function updateLocalCache(Event $event = null)
189
190
];
190
191
191
192
if (null !== $ event ) {
193
+ /** @var BaseIO $logger */
194
+ $ logger = $ event ->getIO ();
192
195
$ arguments = array_replace ($ arguments , $ event ->getArguments ());
193
196
}
194
197
195
- $ installer = self ::createFromCacheDir (self :: getLogger ( $ event ) , $ arguments [Installer::CACHE_DIR_KEY ]);
196
- $ io ->info ('Updating your Pdp local cache. ' );
198
+ $ installer = self ::createFromCacheDir ($ logger , $ arguments [Installer::CACHE_DIR_KEY ]);
199
+ $ io ->write ('Updating your Pdp local cache. ' );
197
200
if ($ installer ->refresh ($ arguments )) {
198
- $ io ->info ('Pdp local cache successfully updated. ' );
201
+ $ io ->write ('Pdp local cache successfully updated. ' );
199
202
die (0 );
200
203
}
201
204
202
- $ io ->error ('The command failed to update Pdp local cache. ' );
205
+ $ io ->writeError ('The command failed to update Pdp local cache. ' );
203
206
die (1 );
204
207
}
205
208
@@ -231,25 +234,6 @@ private function doWrite($messages, bool $newline, bool $stderr, int $verbosity)
231
234
};
232
235
}
233
236
234
- /**
235
- * Detect the Logger instance to use.
236
- *
237
- * @param Event|null $event
238
- *
239
- * @return LoggerInterface
240
- */
241
- private static function getLogger (Event $ event = null ): LoggerInterface
242
- {
243
- if (null !== $ event ) {
244
- /** @var BaseIO $logger */
245
- $ logger = $ event ->getIO ();
246
-
247
- return $ logger ;
248
- }
249
-
250
- return new Logger ();
251
- }
252
-
253
237
/**
254
238
* Detect the vendor path.
255
239
*
0 commit comments