Esempio n. 1
0
 public function registerAutoloaders()
 {
     // echo __DIR__;exit;
     $loader = new Loader();
     $loader->registerNamespaces(array('Modules\\Frontend\\Controllers' => __DIR__ . '/controllers/', 'Modules\\Frontend\\Models' => __DIR__ . '/models/', 'Modules\\Backend\\Controllers' => __DIR__ . '/../backend/controllers/'));
     $loader->register();
 }
Esempio n. 2
0
 public function registerAutoloaders(DiInterface $di = null)
 {
     $l = new Loader();
     $dir = __DIR__;
     $l->registerNamespaces(['Lt\\Backend\\Controllers' => __DIR__ . '/controllers/', 'Lt\\Backend\\Models' => __DIR__ . '/models/']);
     $l->register();
 }
Esempio n. 3
0
 /**
  * Registers the module auto-loader
  */
 public function registerAutoloaders()
 {
     $config = (include __DIR__ . "/../../config/constants.php");
     $loader = new Loader();
     $loader->registerNamespaces(array('App\\Modules\\Frontend\\Controllers' => __DIR__ . '/controllers/', 'App\\Models\\Entities' => $config->application->modelsEntitiesDir, 'App\\Models\\Services' => $config->application->modelsServicesDir, 'App\\Models\\Repositories' => $config->application->modelsRepositoriesDir));
     $loader->register();
 }
Esempio n. 4
0
 /**
  * Registers the module auto-loader
  */
 public function registerAutoloaders(\Phalcon\DiInterface $di = null)
 {
     $loader = new Loader();
     $loader->registerNamespaces(array('HaiQuan\\Frontend\\Controllers' => __DIR__ . '/controllers/', 'HaiQuan\\Backend\\Models' => __DIR__ . '../../backend/models/', 'library' => __DIR__ . '/../../library/', 'Facebook' => __DIR__ . '/../../library/Facebook', 'Minigame' => __DIR__ . '/../../library/Minigame', 'datacenter' => __DIR__ . '/../../datacenter/', 'payment' => __DIR__ . '/../../payment/', 'event' => __DIR__ . '/../../library/Event/'));
     $loader->registerClasses(array("Google_Client" => __DIR__ . '/../../library/Google/src/Google/Client.php'));
     $loader->register();
 }
Esempio n. 5
0
function setDi()
{
    $di = new FactoryDefault();
    $di['router'] = function () use($di) {
        $router = new Router();
        $router->setDefaultModule('mobimall');
        return $router;
    };
    $di['url'] = function () {
        $url = new UrlResolver();
        $url->setBaseUri('/');
        return $url;
    };
    $di['session'] = function () {
        $session = new SessionAdapter();
        // $session->start();
        return $session;
    };
    $loader = new Loader();
    $loader->registerNamespaces(array('Mall\\Mdu' => __DIR__ . '/../apps/mdu'));
    $sysConfig = (include __DIR__ . '/../config/sysconfig.php');
    $di['sysconfig'] = function () use($sysConfig) {
        return $sysConfig;
    };
    $loader->register();
    return $di;
}
Esempio n. 6
0
 private function registerNamespace()
 {
     $loader = new Loader();
     $this->namespace = array_merge($this->namespace, ['Common\\Util' => './module/common/util/', 'Common\\Services' => './module/common/services/']);
     $loader->registerNamespaces($this->namespace);
     $loader->register();
 }
Esempio n. 7
0
 /**
  * Register the services here to make them general or register in the ModuleDefinition to make them module-specific
  */
 public function registerServices()
 {
     $di = new FactoryDefault();
     $loader = new Loader();
     $namespaces = [];
     $map = (require_once __DIR__ . '/../autoload_namespaces.php');
     foreach ($map as $k => $values) {
         $k = trim($k, '\\');
         if (!isset($namespaces[$k])) {
             $dir = '/' . str_replace('\\', '/', $k) . '/';
             $namespaces[$k] = implode($dir . ';', $values) . $dir;
         }
     }
     $loader->registerNamespaces($namespaces);
     $loader->register();
     /**
      * Register a router
      */
     $di->set('router', function () {
         $router = new Router();
         $router->setDefaultModule('frontend');
         //set frontend routes
         $router->mount(new FrontendRoutes());
         //
         return $router;
     });
     $this->setDI($di);
 }
Esempio n. 8
0
 public function registerAutoloaders(DiInterface $di = null)
 {
     $l = new Loader();
     $dir = __DIR__;
     $l->registerNamespaces([self::$ctrlnamespace => __DIR__ . '/']);
     $l->register();
 }
Esempio n. 9
0
 /**
  * Register a specific autoloader for the module
  */
 public function registerAutoloaders(DiInterface $di = NULL)
 {
     $loader = new Loader();
     $loader->registerNamespaces(array('Ecommerce\\Admin\\Controllers' => '../apps/admin/controllers/', 'Ecommerce\\Admin\\Models' => '../apps/admin/models/', 'Ecommerce\\Admin\\Forms' => '../apps/admin/forms/', 'Ecommerce\\Admin\\Helpers' => '../apps/admin/helpers/', 'Ecommerce\\Loja\\Helpers' => '../apps/loja/helpers/'));
     require '../apps/loja/vendor/autoload.php';
     $loader->register();
 }
Esempio n. 10
0
 /**
  * Registers an autoloader related to the module
  *
  * @param DiInterface $di
  */
 public function registerAutoloaders(DiInterface $di = null)
 {
     $config = $this->config;
     $debug = $this->debug;
     $namespace = substr(get_class($this), 0, strripos(get_class($this), '\\'));
     $baseDir = $this::DIR . '/';
     $regs = [$namespace => $baseDir];
     $loader = new Loader();
     // 配置中的名字空间设置
     $namespaceConfig = $config->offsetExists('namespaces') ? $config->namespaces->toArray() : [];
     foreach ($namespaceConfig as $n => $d) {
         $regs[$n] = $d;
     }
     // 检查 controllers 和 models是否存在
     $moduleControllers = $namespace . '\\Controllers';
     $moduleModels = $namespace . '\\Models';
     if (!isset($regs[$moduleControllers])) {
         $regs[$moduleControllers] = $baseDir . 'controllers/';
     }
     if (!isset($regs[$moduleModels])) {
         $regs[$moduleModels] = $baseDir . 'models/';
     }
     $loader->registerNamespaces($regs);
     $loader->register();
 }
 /**
  * If the class isn't already loaded, and an autoloader hasn't been set up
  * for the class (i.e. class not loaded), we will set up our own autoloader
  * for all namespaces and dirs registered and attempt to load the class
  *
  * @param $className
  * @throws Exception
  */
 protected function autoloadClass($className)
 {
     // has the class be loaded?
     if (class_exists($className)) {
         return;
     }
     if (!$this->ourLoader) {
         $this->ourLoader = new Loader();
         $ourLoaderNamespaces = array();
         $ourLoaderDirs = array();
         foreach ($this->namespaces as $ns) {
             if ($ns['ns']) {
                 $ourLoaderNamespaces[$ns['ns']] = $ns['dir'];
             } else {
                 $ourLoaderDirs[] = $ns['dir'];
             }
         }
         $this->ourLoader->registerNamespaces($ourLoaderNamespaces);
         $this->ourLoader->registerDirs($ourLoaderDirs);
     }
     $loaded = $this->ourLoader->autoLoad($className);
     if (!$loaded) {
         throw new \Exception('Unable to load autoload class ' . $className);
     }
 }
Esempio n. 12
0
 public function registerAutoloaders()
 {
     $loader = new Loader();
     $loader->registerNamespaces(['Admin\\Controllers' => ADMINROOT . '/controllers/', 'Admin\\Fields' => ADMINROOT . '/fields/'], true);
     $loader->registerClasses(['AutoAdmin\\Module' => ADMINROOT . '/../autoadmin/module.php'], true);
     $loader->register();
 }
Esempio n. 13
0
 public function registerAutoloaders(DiInterface $dependencyInjector = null)
 {
     global $config;
     $loader = new Loader();
     $loader->registerNamespaces(array('Multiple\\Backend\\Controllers' => $config->backend->controllersDir, 'Multiple\\Backend\\Models' => $config->backend->modelsDir));
     $loader->registerDirs(array($config->backend->controllersDir, $config->backend->modelsDir));
     $loader->register();
 }
Esempio n. 14
0
 /**
  * 注册对应文件到命名空间
  */
 public function registerAutoloaders(DiInterface $dependencyInjector = NULL)
 {
     $loader = new Loader();
     //get_class_methods($loader);
     //注册对应模块
     $loader->registerNamespaces(array('App\\' . ucfirst($this->_module) . '\\Controller' => INDEX_ROOT . 'application/' . $this->_module . '/controller', 'App\\M' => INDEX_ROOT . 'application/_common/model/mysql'));
     $loader->register();
 }
Esempio n. 15
0
 /**
  * Register a specific autoloader for the module
  * @param \Phalcon\DiInterface $di
  */
 public function registerAutoloaders(DiInterface $di = null)
 {
     $config = $this->_config;
     $loader = new Loader();
     $loader->registerNamespaces(array('Imports\\Controllers' => __DIR__ . '/Controllers', 'Imports\\Models' => __DIR__ . '/Models'));
     $loader->registerDirs(array(APP_PATH . $config->application->controllersDir, APP_PATH . $config->application->modelsDir, APP_PATH . $config->application->viewsDir, APP_PATH . $config->application->migrationsDir, APP_PATH . $config->application->pluginsDir, APP_PATH . $config->application->libraryDir, APP_PATH . $config->application->formsDir));
     $loader->register();
 }
Esempio n. 16
0
 /**
  * Register a specific autoloader for the module
  */
 function registerAutoloaders(\Phalcon\DiInterface $di = null)
 {
     $loader = new Loader();
     $module = $di->getShared('router')->getModuleName();
     $namespace = $di->getShared('router')->getNamespaceName();
     $namespace = str_replace(['Models', 'Controllers'], "", $namespace);
     $loader->registerNamespaces(array($namespace . 'Controllers' => '../app/controllers/Frontend/Controllers', $namespace . 'Models' => '../app/controllers/Frontend/models/'))->register();
 }
Esempio n. 17
0
 /**
  * Register a specific autoloader for the module
  */
 public function registerAutoloaders(DiInterface $dependencyInjector = null)
 {
     $loader = new Loader();
     $loader->registerNamespaces(array('Promoziti\\Modules\\Business\\Controllers' => __DIR__ . '/controllers/', 'Promoziti\\Models\\Entities' => __DIR__ . '/../../models/entities/', 'Promoziti\\Models\\Services' => __DIR__ . '/../../models/services/', 'Promoziti\\Models\\Services\\Service' => __DIR__ . '/../../models/services/service/', 'Promoziti\\Models\\Services\\Exceptions' => __DIR__ . '/../../models/services/exceptions/', 'Promoziti\\Models\\Repositories' => __DIR__ . '/../../models/repositories/', 'Promoziti\\Models\\Repositories\\Repository' => __DIR__ . '/../../models/repositories/repository/', 'Promoziti\\Models\\Repositories\\Exceptions' => __DIR__ . '/../../models/repositories/exceptions/', 'Promoziti\\Lib\\Core' => __DIR__ . '/../../lib/core/', 'Promoziti\\Lib\\Core\\Mail' => __DIR__ . '/../../lib/core/mail/', 'Promoziti\\Lib\\Core\\Crypt' => __DIR__ . '/../../lib/core/crypt/'));
     include_once __DIR__ . '/../../lib/vendors/aws-sdk-php-2.7.6/aws-autoloader.php';
     include_once __DIR__ . '/../../lib/vendors/PHPExcel/Classes/PHPExcel.php';
     $loader->register();
 }
Esempio n. 18
0
 public function registerAutoloaders(DiInterface $di = null)
 {
     $path = $di->getShared('config')->modules->poll->path;
     $path = str_replace('Module.php', '', $path);
     $loader = new Loader();
     $loader->registerNamespaces(array('Socialveo\\Poll\\Models' => $path . 'models/', 'Socialveo\\Poll\\Controllers' => $path . 'controllers/', 'Socialveo\\Poll\\Plugins' => $path . 'plugins/'));
     $loader->register();
 }
Esempio n. 19
0
 /**
  * Helper to load the a controller
  *
  * @coversNothing
  */
 public function getController($name)
 {
     $loader = new Loader();
     $loader->registerClasses(['\\App\\Modules\\Backend\\Controllers\\API\\' . ucfirst($name) . 'Controller' => ROOT_PATH . 'modules/backend/controller/api/'])->register();
     $indexCntrl = new \App\Modules\Backend\Controllers\API\IndexController();
     $this->assertNotNull($indexCntrl, 'Make sure the index controller could be loaded');
     return $indexCntrl;
 }
Esempio n. 20
0
 /**
  * Register a specific autoloader for the module
  * @param \Phalcon\DiInterface $di
  */
 public function registerAutoloaders(DiInterface $di = null)
 {
     $config = $this->_config;
     $loader = new Loader();
     $loader->registerNamespaces(array(__NAMESPACE__ . '\\Controllers' => __DIR__ . '/controllers', __NAMESPACE__ . '\\Models' => __DIR__ . '/models', __NAMESPACE__ . '\\Forms' => __DIR__ . '/forms'));
     $loader->registerDirs(array($config->application->controllersDir, $config->application->modelsDir, $config->application->migrationsDir, $config->application->formsDir));
     $loader->register();
 }
Esempio n. 21
0
 /**
  * Registers namespaces for models and services within modules
  *
  * @param $modules
  * @internal
  */
 private function registerSharedData($modules)
 {
     $loader = new Loader();
     foreach ($modules as $name => $module) {
         $loader->registerNamespaces(array($name . '\\Forms' => dirname($module['path']) . '/forms/', $name . '\\Models' => dirname($module['path']) . '/models/', $name . '\\Services' => dirname($module['path']) . '/services/', $name . '\\Components' => dirname($module['path']) . '/components/'), true);
     }
     $loader->register();
 }
Esempio n. 22
0
 /**
  * オートロード設定を実行
  */
 function autoloadRegister()
 {
     $conf = new ConfigLoader('autoload');
     $loadConf = $conf->getArray();
     if (!empty($loadConf)) {
         $loader = new Loader();
         $loader->registerNamespaces($loadConf)->register();
     }
 }
Esempio n. 23
0
 /**
  * Register services
  */
 public function register()
 {
     $loader = new PhalconLoader();
     $loader->registerNamespaces($this->config->loader->namespaces->toArray());
     $loader->register();
     $this->container->set('loader', function () use($loader) {
         return $loader;
     });
 }
 public function setUp()
 {
     parent::setUp();
     $this->loader = $this->di->getLoader();
     $strModule = 'App\\Modules\\Api';
     $strModuleDir = $this->di->getConfig()->application->modulesDir . DIRECTORY_SEPARATOR . 'api';
     $this->loader->registerNamespaces(array($strModule => $strModuleDir), true);
     $this->module = new Module();
 }
Esempio n. 25
0
 /**
  * init
  */
 protected function init()
 {
     $loader = new Loader();
     // \App base
     $loader->registerNamespaces(['App' => $this->path() . '/']);
     // Other
     $loader->registerDirs([$this->libPath()]);
     $loader->register();
 }
 /**
  * Initializes the loader
  */
 protected function initLoader()
 {
     $config = $this->di['config'];
     // Creates the autoloader
     $loader = new PhLoader();
     $loader->registerDirs(array($config->application->controllersDir, $config->application->modelsDir));
     $loader->register();
     // Dump it in the DI to reuse it
     $this->di['loader'] = $loader;
 }
Esempio n. 27
0
 protected function initLoader()
 {
     $loader = new Loader();
     $loader->registerNamespaces(['Actions' => APP_PATH . '/actions/', 'Base' => APP_PATH . '/base/', 'Controllers' => APP_PATH . '/controllers/', 'Db' => APP_PATH . '/models/', 'Lib' => APP_PATH . '/library/', 'Tasks' => CLI_PATH . '/tasks/']);
     $loader->registerClasses(['__' => VENDOR_PATH . '/Underscore.php']);
     $loader->register();
     // Autoload vendor dependencies
     require_once VENDOR_PATH . '/autoload.php';
     $this->di['loader'] = $loader;
 }
Esempio n. 28
0
 /**
  * Registers an autoloader related to the module
  *
  * @param DiInterface $dependencyInjector
  */
 public function registerAutoloaders(DiInterface $dependencyInjector = null)
 {
     $loader = new Loader();
     //注册命名空间
     $loader->registerNamespaces(array('Api\\Controllers' => __DIR__ . '/controllers/', 'Api\\Models' => __DIR__ . '/models/'));
     //注册基本模型类名
     $loader->registerClasses(['ModelBase' => APP_PATH . '/base/ModelBase.php']);
     //惰性加载文件,模型、第三类库
     $loader->registerDirs(array(APP_PATH . '/library/', __DIR__ . '/models/'));
     $loader->register();
 }
Esempio n. 29
0
 public function registerAutoloaders(\Phalcon\DiInterface $manager = NULL)
 {
     $loader = new Loader();
     $loader->registerNamespaces(array(ucfirst($this->moduleName) . '\\Controllers' => __DIR__ . '/controllers/', 'Multiple\\Components' => APPLICATION_PATH . '/' . $this->config->application->componentsDir, 'Multiple\\Models' => APPLICATION_PATH . '/' . $this->config->application->modelsDir, 'Multiple\\Plugins' => APPLICATION_PATH . '/' . $this->config->application->pluginsDir, 'Multiple\\Librarys' => APPLICATION_PATH . '/' . $this->config->application->libraryDir));
     $loader->register();
     $manager->set('logger', function () {
         $monthNow = date('Y-m-d', time());
         $pathLog = sprintf('%s/%s/%s/%s.log', APPLICATION_PATH, $this->config->application->logsDir, $this->moduleName, $monthNow);
         $logger = new LogFile($pathLog);
         return $logger;
     });
 }
Esempio n. 30
0
 public function registerAutoloaders(\Phalcon\DiInterface $manager = NULL)
 {
     $loader = new Loader();
     $loader->registerNamespaces(array(ucfirst($this->moduleName) . '\\Controllers' => __DIR__ . '/controllers/', 'Multiple\\Components' => APPLICATION_PATH . $manager->get('config')->application->componentsDir, 'Multiple\\Models' => APPLICATION_PATH . $manager->get('config')->application->modelsDir, 'Multiple\\Plugins' => APPLICATION_PATH . $manager->get('config')->application->pluginsDir));
     $loader->register();
     $manager->set('logger', function () use($manager) {
         $monthNow = date("Y-m-d", time());
         $pathLog = APPLICATION_PATH . $manager->get('config')->application->logsDir . '/' . $this->moduleName . '/' . $monthNow . '.log';
         $logger = new LogFile($pathLog);
         return $logger;
     });
 }