/** * Initialize autoloader for this service. * * Each service get its own autoloader attached to SPL autoloaders. * * @param string $service The name of the service to init autoloader for * * @author Benjamin Carl <*****@*****.**> * @return void * @access protected */ protected function initAutoloader($service) { // Register services custom autoloader $autoloaderService = new Doozr_Loader_Autoloader_Spl_Config(); $autoloaderService->_namespace('Doozr_' . $service)->namespaceSeparator('_')->addExtension('php')->path(DOOZR_DOCUMENT_ROOT . 'Service')->description('Doozr\'s ' . $service . ' service autoloader. Timestamp: ' . time()); // Add to SPL through facade $this->autoloader = Doozr_Loader_Autoloader_Spl_Facade::attach($autoloaderService); }
/** * Registers an autoloader instance SPL with highest priority for loading classes of the app. * * @param object $app The app configuration object * * @author Benjamin Carl <*****@*****.**> */ protected function registerAutoloader($app) { // now configure a new autoloader spl configuration $autoloaderApp = new Doozr_Loader_Autoloader_Spl_Config(); $autoloaderApp->_namespace($app->namespace)->namespaceSeparator('_')->addExtension('php')->path(substr($app->path, 0, -1))->description('Autoloader for App classes with namespace: "' . $app->namespace . '"')->priority(0); Doozr_Loader_Autoloader_Spl_Facade::attach([$autoloaderApp]); }
| EXTEND PHP's FUNCTIONALITY +---------------------------------------------------------------------------------------------------------------------*/ require_once DOOZR_DOCUMENT_ROOT . 'Doozr/Extend.php'; /*---------------------------------------------------------------------------------------------------------------------- | AUTOLOADING (SPL) +---------------------------------------------------------------------------------------------------------------------*/ // SPL facade files configuration + facade itself require_once DOOZR_DOCUMENT_ROOT . 'Doozr/Loader/Autoloader/Spl/Configuration.php'; require_once DOOZR_DOCUMENT_ROOT . 'Doozr/Loader/Autoloader/Spl/Facade.php'; // now configure a new autoloader spl configuration $autoloaderDoozr = new Doozr_Loader_Autoloader_Spl_Config(); $autoloaderDoozr->_namespace('Doozr')->namespaceSeparator('_')->addExtension('php')->path(substr(DOOZR_DOCUMENT_ROOT, 0, -1))->description('Doozr\'s autoloader for loading classes of Doozr below "src/".')->priority(0); /* * Autoloader for Doozr - Services (native) */ $autoloaderService = new Doozr_Loader_Autoloader_Spl_Config(); $autoloaderService->_namespace('Doozr')->namespaceSeparator('_')->addExtension('php')->path(DOOZR_DOCUMENT_ROOT . 'Service')->description('Doozr\'s autoloader for loading Services of Doozr below "src/Service".')->priority(1); /* * The facade itself is auto instanciating singleton within the * register method if not already instantiated! So don't worry * just call the register() method pass a configuration and everything * is handled magically (: */ Doozr_Loader_Autoloader_Spl_Facade::attach(array($autoloaderDoozr, $autoloaderService)); /*---------------------------------------------------------------------------------------------------------------------- | ERROR & EXCEPTION-HANDLING (HOOK) ---------------------------------------------------------------------------------------------------------------------*/ // Install error handler which is used in case that DOOZR_APP_ENVIRONMENT is not development (= make use of Whoops) if (Doozr_Kernel::APP_ENVIRONMENT_TESTING !== DOOZR_APP_ENVIRONMENT) { // ERROR-HANDLER: register error-handler require_once DOOZR_DOCUMENT_ROOT . 'Doozr/Handler/Error.php';