/** * Constructor * * Prevent creating instances of this class by making the constructor private * * @param array $config An optional array with configuration options. */ private final function __construct($config = array()) { /** * Setup the configuration */ if (isset($config['debug'])) { self::$_debug = $config['debug']; } else { self::$_debug = false; } if (isset($config['cache'])) { self::$_cache = $config['cache']; } else { self::$_cache = false; } if (isset($config['root_path'])) { self::$_root_path = $config['root_path']; } else { self::$_root_path = realpath($_SERVER['DOCUMENT_ROOT']); } if (isset($config['base_path'])) { self::$_base_path = $config['base_path']; } else { self::$_base_path = self::$_root_path; } if (isset($config['vendor_path'])) { self::$_vendor_path = $config['vendor_path']; } else { self::$_vendor_path = self::$_root_path . '/vendor'; } /** * Load the legacy functions */ require_once dirname(__FILE__) . '/legacy.php'; /** * Load the class locator */ require_once dirname(__FILE__) . '/class/loader/loader.php'; $loader = new Library\ClassLoader(); $loader->setDebug(self::isDebug()); $loader->setCache(self::isCache()); //Register the component class locator $loader->registerLocator(new Library\ClassLocatorComponent(), true); //Register the composer class locator if (file_exists($this->getVendorPath())) { $loader->registerLocator(new Library\ClassLocatorComposer()); } //Register the PSR locator $loader->registerLocator(new Library\ClassLocatorPsr()); /** * Setup the object manager */ $manager = new Library\ObjectManager($config); $manager->setCache(self::isCache()); $manager->setDebug(self::isDebug()); $manager->setClassLoader($loader); //Register the component object locator $manager->registerLocator('lib:object.locator.component'); //Warm-up the stream factory $manager->getObject('lib:filesystem.stream.factory'); //Store the object manager self::$__object_manager = $manager; }