From a615ba3ccd82fd08520e356061b252a1255d5594 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tobias=20St=C3=B6ckler?= <tobiasstoeckler@googlemail.com>
Date: Thu, 5 Nov 2015 14:02:29 +0100
Subject: [PATCH] by tstoeckler: Clean-up some namespaces et al

---
 .../Exception/InvalidLibraryDependencyException.php      | 4 ++--
 .../Exception/LibraryClassNotFoundException.php          | 3 ++-
 .../Exception/LibraryDefinitionNotFoundException.php     | 3 ++-
 src/ExternalLibrary/Registry/ExternalLibraryRegistry.php | 9 +++++----
 src/StreamWrapper/PhpLibraryFilesStream.php              | 1 +
 5 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/ExternalLibrary/Exception/InvalidLibraryDependencyException.php b/src/ExternalLibrary/Exception/InvalidLibraryDependencyException.php
index a3c3353..004691e 100644
--- a/src/ExternalLibrary/Exception/InvalidLibraryDependencyException.php
+++ b/src/ExternalLibrary/Exception/InvalidLibraryDependencyException.php
@@ -6,9 +6,9 @@
  */
 
 namespace Drupal\libraries\ExternalLibrary\Exception;
-use Drupal\libraries\ExternalLibrary\DependencyAccessorTrait;
+use Drupal\libraries\ExternalLibrary\Utility\DependencyAccessorTrait;
 use Drupal\libraries\ExternalLibrary\ExternalLibraryInterface;
-use Drupal\libraries\ExternalLibrary\LibraryAccessorTrait;
+use Drupal\libraries\ExternalLibrary\Utility\LibraryAccessorTrait;
 
 /**
  *
diff --git a/src/ExternalLibrary/Exception/LibraryClassNotFoundException.php b/src/ExternalLibrary/Exception/LibraryClassNotFoundException.php
index aadfaef..000fa5d 100644
--- a/src/ExternalLibrary/Exception/LibraryClassNotFoundException.php
+++ b/src/ExternalLibrary/Exception/LibraryClassNotFoundException.php
@@ -6,7 +6,8 @@
  */
 
 namespace Drupal\libraries\ExternalLibrary\Exception;
-use Drupal\libraries\ExternalLibrary\LibraryIdAccessorTrait;
+
+use Drupal\libraries\ExternalLibrary\Utility\LibraryIdAccessorTrait;
 use Exception;
 
 /**
diff --git a/src/ExternalLibrary/Exception/LibraryDefinitionNotFoundException.php b/src/ExternalLibrary/Exception/LibraryDefinitionNotFoundException.php
index 53ebfe0..80621f9 100644
--- a/src/ExternalLibrary/Exception/LibraryDefinitionNotFoundException.php
+++ b/src/ExternalLibrary/Exception/LibraryDefinitionNotFoundException.php
@@ -6,7 +6,8 @@
  */
 
 namespace Drupal\libraries\ExternalLibrary\Exception;
-use Drupal\libraries\ExternalLibrary\LibraryIdAccessorTrait;
+
+use Drupal\libraries\ExternalLibrary\Utility\LibraryIdAccessorTrait;
 use Exception;
 
 /**
diff --git a/src/ExternalLibrary/Registry/ExternalLibraryRegistry.php b/src/ExternalLibrary/Registry/ExternalLibraryRegistry.php
index 0c59a64..b31cea8 100644
--- a/src/ExternalLibrary/Registry/ExternalLibraryRegistry.php
+++ b/src/ExternalLibrary/Registry/ExternalLibraryRegistry.php
@@ -44,7 +44,7 @@ class ExternalLibraryRegistry implements ExternalLibraryRegistryInterface {
       throw new LibraryDefinitionNotFoundException($id);
     }
     $definition = $this->getDefinition($id);
-    $class = $this->getClass($definition);
+    $class = $this->getClass($id, $definition);
     return $class::create($id, $definition);
   }
 
@@ -91,6 +91,8 @@ class ExternalLibraryRegistry implements ExternalLibraryRegistryInterface {
   /**
    * Returns the library class for a library definition.
    *
+   * @param string $id
+   *   The ID of the external library.
    * @param array $definition
    *   The library definition array parsed from the definition JSON file.
    *
@@ -99,11 +101,10 @@ class ExternalLibraryRegistry implements ExternalLibraryRegistryInterface {
    *
    * @throws \Drupal\libraries\ExternalLibrary\Exception\LibraryClassNotFoundException
    */
-  protected function getClass(array $definition) {
+  protected function getClass($id, array $definition) {
     // @todo Reconsider
     if (!isset($definition['class'])) {
-      // @todo What if $definition['id'] is not set?
-      throw new LibraryClassNotFoundException($definition['id']);
+      throw new LibraryClassNotFoundException($id);
     }
     // @todo Make sure the class exists.
     return $definition['class'];
diff --git a/src/StreamWrapper/PhpLibraryFilesStream.php b/src/StreamWrapper/PhpLibraryFilesStream.php
index abfcbb7..a05a372 100644
--- a/src/StreamWrapper/PhpLibraryFilesStream.php
+++ b/src/StreamWrapper/PhpLibraryFilesStream.php
@@ -39,6 +39,7 @@ class PhpLibraryFilesStream extends LocalStream {
    * {@inheritdoc}
    */
   public function getDirectoryPath() {
+    // @todo Provide support for site-specific directories, etc.
     return 'sites/all/libraries';
   }
 
-- 
GitLab