1818use Http \Discovery \StreamFactoryDiscovery ;
1919use Http \Discovery \UriFactoryDiscovery ;
2020use Http \Message \MessageFactory ;
21- use Http \ Message \ SteamFactory ;
21+ use Nyholm \ Psr7 \ Factory \ StreamFactory ;
2222use Psr \Cache \CacheItemPoolInterface ;
2323
2424/**
@@ -304,12 +304,12 @@ public function setEnterpriseUrl($enterpriseUrl)
304304 $ this ->removePlugin (Plugin \AddHostPlugin::class);
305305 $ this ->removePlugin (PathPrepend::class);
306306
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 ' ))));
309309 }
310310
311311 /**
312- * Add a new plugin to the chain
312+ * Add a new plugin to the end of the plugin chain.
313313 *
314314 * @param Plugin $plugin
315315 */
@@ -319,6 +319,17 @@ public function addPlugin(Plugin $plugin)
319319 $ this ->httpClientModified = true ;
320320 }
321321
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+
322333 /**
323334 * Remove a plugin by its fully qualified class name (FQCN).
324335 *
0 commit comments