Permalink
Browse files

Initial commit of new Composer-based class loading interface.

  • Loading branch information...
1 parent d42184c commit ec39c7bcf7c7c06b6ce9bc2c83918cbffaefae83 @nateabele nateabele committed Sep 18, 2012
Showing with 24 additions and 0 deletions.
  1. +3 −0 composer.json
  2. +21 −0 core/Libraries.php
View
@@ -18,5 +18,8 @@
"require": {
"php": ">=5.3.6",
"composer/installers": "dev-master"
+ },
+ "autoload": {
+ "psr-0": {"lithium\\": "/" }
}
}
View
@@ -72,6 +72,13 @@ class Libraries {
protected static $_configurations = array();
/**
+ * A Composer-compatible SPL autoloader implementation.
+ *
+ * @var object
+ */
+ protected static $_loader = null;
+
+ /**
* Contains a cascading list of search path templates, indexed by base object type.
*
* Used by `Libraries::locate()` to perform service location. This allows new types of
@@ -337,6 +344,20 @@ protected static function _configure($config) {
}
/**
+ * Configures dependency libraries using Composer's generated autoloader to introspect
+ * dependencies.
+ *
+ * @param string $file A Composer-generated autoload file, which returns a PSR-0-compatible
+ * autloader instance.
+ */
+ public static function loadConfig($file) {
+ if (static::$_loader) {
+ throw new ConfigException("Class loader already configured.");
+ }
+ static::$_loader = require $file;
+ }
+
+ /**
* Allows library information to be retrieved in various ways, including:
*
* By name:

0 comments on commit ec39c7b

Please sign in to comment.