18
18
use Http \Discovery \StreamFactoryDiscovery ;
19
19
use Http \Discovery \UriFactoryDiscovery ;
20
20
use Http \Message \MessageFactory ;
21
- use Http \ Message \ SteamFactory ;
21
+ use Nyholm \ Psr7 \ Factory \ StreamFactory ;
22
22
use Psr \Cache \CacheItemPoolInterface ;
23
23
24
24
/**
@@ -304,12 +304,12 @@ public function setEnterpriseUrl($enterpriseUrl)
304
304
$ this ->removePlugin (Plugin \AddHostPlugin::class);
305
305
$ this ->removePlugin (PathPrepend::class);
306
306
307
- $ this ->addPlugin (new Plugin \AddHostPlugin (UriFactoryDiscovery::find ()->createUri ($ enterpriseUrl )));
308
- $ this ->addPlugin (new PathPrepend (sprintf ('/api/%s/ ' , $ this ->getOption ('api_version ' ))));
307
+ $ this ->prependPluging (new Plugin \AddHostPlugin (UriFactoryDiscovery::find ()->createUri ($ enterpriseUrl )));
308
+ $ this ->prependPluging (new PathPrepend (sprintf ('/api/%s/ ' , $ this ->getOption ('api_version ' ))));
309
309
}
310
310
311
311
/**
312
- * Add a new plugin to the chain
312
+ * Add a new plugin to the end of the plugin chain.
313
313
*
314
314
* @param Plugin $plugin
315
315
*/
@@ -319,6 +319,17 @@ public function addPlugin(Plugin $plugin)
319
319
$ this ->httpClientModified = true ;
320
320
}
321
321
322
+ /**
323
+ * Prepend plugin chain with a plugin.
324
+ *
325
+ * @param Plugin $plugin
326
+ */
327
+ public function prependPluging (Plugin $ plugin )
328
+ {
329
+ array_unshift ($ this ->plugins , $ plugin );
330
+ $ this ->httpClientModified = true ;
331
+ }
332
+
322
333
/**
323
334
* Remove a plugin by its fully qualified class name (FQCN).
324
335
*
0 commit comments