Пример #1
0
 /**
  * Register the autoloader specific to the current module
  * @access public
  * @return \Phalcon\Loader\Loader()
  */
 public function registerAutoloaders()
 {
     $loader = new Loader();
     $loader->registerNamespaces(['Modules\\Frontend\\Controllers' => $this->_config['application']['controllersFront'], 'Models' => $this->_config['application']['modelsDir'], 'Libraries' => $this->_config['application']['libraryDir'], 'Modules\\Frontend\\Plugins' => APP_PATH . '/Modules/' . self::MODULE . '/Plugins/']);
     $loader->register();
     if (isset($this->_config->database->profiler)) {
         $namespaces = array_merge($loader->getNamespaces(), ['Phalcon\\Debugger' => APP_PATH . '/Libraries/Debugger', 'Phalcon\\Utils' => APP_PATH . '/Libraries/PrettyExceptions/Library/Phalcon/Utils']);
         $loader->registerNamespaces($namespaces);
         // call pretty loader
         set_error_handler(function ($errorCode, $errorMessage, $errorFile, $errorLine) {
             $p = new \Phalcon\Utils\PrettyExceptions();
             $p->handleError($errorCode, $errorMessage, $errorFile, $errorLine);
         });
     }
 }
Пример #2
0
 /**
  * Register the autoloader specific to the current module
  * @access public
  * @return \Phalcon\Loader\Loader()
  */
 public function registerAutoloaders()
 {
     $loader = new Loader();
     $loader->registerNamespaces(['Modules\\Backend\\Controllers' => $this->_config['application']['controllersBack'], 'Modules\\Backend\\Forms' => $this->_config['application']['formsBack'], 'Models' => $this->_config['application']['modelsDir'], 'Helpers' => $this->_config['application']['helpersDir'], 'Libraries' => $this->_config['application']['libraryDir'], 'Plugins' => $this->_config['application']['pluginsDir']]);
     $loader->register();
     if (APPLICATION_ENV == 'development') {
         $namespaces = array_merge($loader->getNamespaces(), ['Phalcon\\Utils' => APP_PATH . '/Libraries/PrettyExceptions/Library/Phalcon/Utils']);
         $loader->registerNamespaces($namespaces);
         // call pretty loader
         set_error_handler(function ($errorCode, $errorMessage, $errorFile, $errorLine) {
             $p = new \Phalcon\Utils\PrettyExceptions();
             $p->handleError($errorCode, $errorMessage, $errorFile, $errorLine);
         });
     }
 }
use Phalcon\Loader;
use Phalcon\Mvc\Dispatcher;
$oEventsManager = new Manager();
//$loader = new \Phalcon\Loader();
$di->setShared('loader', function () use($oEventsManager, $di) {
    $oLoader = new Loader();
    $oConfig = $di->getConfig();
    $oLoader->setEventsManager($oEventsManager);
    $oLoader->registerNamespaces(array('App\\Modules' => $oConfig->application->modulesDir, 'App\\Hooks' => $oConfig->application->hooksDir, 'App\\Util' => $oConfig->application->utilDir, 'App\\Core\\Interfaces' => $oConfig->application->ifaceDir, 'App\\Modules\\Api' => __DIR__ . '/../../app/modules/api'));
    $oLogger = $di->getFileLogger();
    //	$oLogger->debug('namespaces registered in main loader');
    //	foreach ($oConfig->modules as $strNamespace => $strDirectory) {
    //
    //		$arNamespace = array(
    //			'App\Modules\\' . $strNamespace => $oConfig->application->modulesDir . '/' . $strDirectory
    //		);
    //
    //		$oLogger->debug('trying to register namespaces: ' . print_r($arNamespace, true));
    //
    //		$oLoader->registerNamespaces($arNamespace);
    //	}
    //	$oLogger = $di->getFileLogger();
    $oLogger->debug('config already read; common loader initialization; here`s the beginning for "' . $di->getRequest()->getURI() . '"' . str_repeat('_', 170) . PHP_EOL . print_r($oLoader->getNamespaces(), true));
    $oLoader->register();
    return $oLoader;
});
//$oEventsManager->attach('loader', function($event, $loader, $strClassName) use ($di) {
//
//	$oLogger = $di->getFileLogger();
//	$oLogger->debug('common loader: ' . $event->getType() . ': trying "' . $loader->getCheckedPath() . '" parameter is "' . $strClassName . '"');
//});
Пример #4
0
 public function getNamespaces()
 {
     return parent::getNamespaces();
 }