From 2eca15e75a9d828163afa89e06bfa79048d72240 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20St=C3=B6ckler?= <tstoeckler@gmail.com> Date: Fri, 16 Oct 2015 14:32:22 +0200 Subject: [PATCH] Remove HTTP handling from LibraryDefinitionsStream --- .../LibraryDefinitionsStream.php | 39 +------------------ 1 file changed, 2 insertions(+), 37 deletions(-) diff --git a/src/StreamWrapper/LibraryDefinitionsStream.php b/src/StreamWrapper/LibraryDefinitionsStream.php index d963a2d..58da4b2 100644 --- a/src/StreamWrapper/LibraryDefinitionsStream.php +++ b/src/StreamWrapper/LibraryDefinitionsStream.php @@ -7,11 +7,8 @@ namespace Drupal\libraries\StreamWrapper; -use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\StreamWrapper\LocalStream; use Drupal\Core\StreamWrapper\StreamWrapperInterface; -use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\GuzzleException; /** * Provides a stream wrapper for library definitions. @@ -30,13 +27,6 @@ class LibraryDefinitionsStream extends LocalStream { */ protected $configFactory; - /** - * The HTTP client. - * - * @var \GuzzleHttp\ClientInterface - */ - protected $httpClient; - /** * Constructs an external library registry. * @@ -44,7 +34,6 @@ class LibraryDefinitionsStream extends LocalStream { */ public function __construct() { $this->configFactory = \Drupal::configFactory(); - $this->httpClient = \Drupal::httpClient(); } /** @@ -72,39 +61,15 @@ class LibraryDefinitionsStream extends LocalStream { * {@inheritdoc} */ public function getDirectoryPath() { - print 'Directory path: ' . $this->getConfig('local.path') . PHP_EOL; return $this->getConfig('local.path'); } /** * {@inheritdoc} */ - public function getExternalUrl() { - if ($this->getConfig('remote.enable')) { - $url = $this->getConfig('remote.url'); - return $url . '/' . $this->uri; + function getExternalUrl() { + throw new \LogicException('Library definitions should not be public.'); } - } - - public function url_stat($uri, $flags) { - $status = parent::url_stat($uri, $flags); - if (($status === FALSE) && $this->getConfig('remote.enable')) { - $url = $this->getConfig('remote.url'); - try { - $response = $this->httpClient->request('GET', $url . '/' . $this->getTarget($uri)); - print 'Local path: ' . $this->getLocalPath($uri) . PHP_EOL; - print 'Body: ' . $response->getBody() . PHP_EOL; - $written = file_put_contents($this->getLocalPath($uri), $response->getBody()); - if ($written !== FALSE) { - $status = parent::url_stat($uri, $flags); - } - } - catch (GuzzleException $exception) { - // $status is already FALSE, nothing to do. - } - } - return $status; - } /** * Fetches a configuration value from the library definitions configuration. -- GitLab