public static function getLoader()
 {
     if (null !== static::$loader) {
         return static::$loader;
     }
     spl_autoload_register(array('ComposerAutoloaderInitFilesAutoloadOrder', 'loadClassLoader'));
     static::$loader = $loader = new \Composer\Autoload\ClassLoader();
     spl_autoload_unregister(array('ComposerAutoloaderInitFilesAutoloadOrder', 'loadClassLoader'));
     $vendorDir = dirname(__DIR__);
     $baseDir = dirname($vendorDir);
     $map = (require __DIR__ . '/autoload_namespaces.php');
     foreach ($map as $namespace => $path) {
         $loader->add($namespace, $path);
     }
     $classMap = (require __DIR__ . '/autoload_classmap.php');
     if ($classMap) {
         $loader->addClassMap($classMap);
     }
     $loader->register();
     require $vendorDir . '/c/lorem/testC.php';
     require $vendorDir . '/z/foo/testA.php';
     require $baseDir . '/root.php';
     require $vendorDir . '/b/bar/testB.php';
     require $vendorDir . '/d/d/testD.php';
     require $vendorDir . '/e/e/testE.php';
     return $loader;
 }
Example #2
0
 /**
  * 初始化加载器
  *
  * @return \Powernote\Autoloader\ClassAliasLoader
  */
 public static function init()
 {
     if (static::$loader == null) {
         static::$loader = new self();
     }
     return static::$loader;
 }
Example #3
0
 public static function initialize($paths, $baseNamespace = 'App')
 {
     static::$baseNamespace = rtrim($baseNamespace, '\\') . '\\';
     static::$config = new Config(APP_LOCAL ? $paths['config'] . 'local/' : $paths['config']);
     static::$paths = $paths;
     static::$loader = new Loader();
     static::$loader->registerNamespaces([static::$baseNamespace . 'Assets' => $paths['assets'], static::$baseNamespace . 'Bootstrap' => $paths['bootstrap'], static::$baseNamespace . 'Components' => $paths['components'], static::$baseNamespace . 'Helpers' => $paths['helpers'], static::$baseNamespace . 'Libraries' => $paths['libraries'], static::$baseNamespace . 'Models' => $paths['models'], static::$baseNamespace . 'Modules' => $paths['modules']]);
     static::$loader->register();
 }
 /**
  * Makes autoloader.
  *
  * @return ClassLoader The class loader
  */
 public static function make()
 {
     if (!static::$loader) {
         $loader = new ClassLoader();
         $loader->register();
         static::$loader = $loader;
     }
     return static::$loader;
 }
Example #5
0
 /**
  * 初始化加载器
  *
  * @return \Powernote\Autoloader\ClassLoader
  */
 public static function init()
 {
     if (static::$loader == null) {
         static::$loader = new self();
         // 添加框架名称空间加载路径
         static::$loader->addNamespace('Powernote', realpath(__DIR__ . '/../'), true);
     }
     return static::$loader;
 }
Example #6
0
 public function __construct()
 {
     global $autoloader;
     static::$loader = $autoloader;
     session_start();
     parent::__construct();
     require_once __DIR__ . '/version.php';
     // Setup aliases
     $this->setupAliases();
     // Load translations
     $this->loadTranslations();
     // Load common functions
     require __DIR__ . '/common.php';
     // Load plugins
     $this->loadPlugins();
 }
Example #7
0
 public static function getLoader()
 {
     if (null !== static::$loader) {
         return static::$loader;
     }
     static::$loader = $loader = new \Composer\Autoload\ClassLoader();
     $vendorDir = dirname(__DIR__);
     $baseDir = dirname($vendorDir);
     $map = (require __DIR__ . '/autoload_namespaces.php');
     foreach ($map as $namespace => $path) {
         $loader->add($namespace, $path);
     }
     $classMap = (require __DIR__ . '/autoload_classmap.php');
     if ($classMap) {
         $loader->addClassMap($classMap);
     }
     $loader->register();
     return $loader;
 }
Example #8
0
 /**
  * Load DI container config from the unit file into the given container builder.
  * 
  * @param ContainerBuilder $builder
  * 
  * @throws \RuntimeException
  */
 public function load(ContainerBuilder $builder)
 {
     if (static::$loader === NULL) {
         static::$loader = $this->createUnitLoader();
     }
     try {
         $unit = (static::$loader)($this->assertFile($this->file));
     } catch (\Throwable $e) {
         throw new \RuntimeException(sprintf('Failed to include unit: "%s"', $this->file), 0, $e);
     }
     if (!$unit instanceof \Closure) {
         $type = is_object($unit) ? get_class($unit) : gettype($unit);
         throw new \RuntimeException(sprintf('Unit requires a closure, value returned by "%s" is %s', $this->file, $type));
     }
     try {
         $unit($builder);
     } catch (\Throwable $e) {
         throw new \RuntimeException(sprintf('Failed to load unit "%s"', $this->file), 0, $e);
     }
 }
Example #9
0
 protected function __construct($registry)
 {
     if (!isset($registry)) {
         $registry = new Registry();
         $registry->set('db', DB::getDB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE));
     }
     $this->registry = $registry;
     if (is_null(static::$newConfig)) {
         static::$newConfig = $this->registry->get('config');
     }
     $this->config = static::$newConfig;
     if (is_null(static::$db)) {
         static::$db = $this->registry->get('db');
     }
     if (is_null(static::$loader)) {
         static::$loader = $this->registry->get('load');
     }
     $this->load = static::$loader;
     $this->log = $this->registry->get("log");
 }
Example #10
0
 public static function getLoader()
 {
     if (null !== static::$loader) {
         return static::$loader;
     }
     spl_autoload_register(array('ComposerAutoloaderInitcaccbb1dae7e5bd0f3d1bf80a43364f8', 'loadClassLoader'));
     static::$loader = $loader = new \Composer\Autoload\ClassLoader();
     spl_autoload_unregister(array('ComposerAutoloaderInitcaccbb1dae7e5bd0f3d1bf80a43364f8', 'loadClassLoader'));
     $vendorDir = dirname(__DIR__);
     $baseDir = dirname($vendorDir);
     $map = (require __DIR__ . '/autoload_namespaces.php');
     foreach ($map as $namespace => $path) {
         $loader->add($namespace, $path);
     }
     $classMap = (require __DIR__ . '/autoload_classmap.php');
     if ($classMap) {
         $loader->addClassMap($classMap);
     }
     $loader->register();
     return $loader;
 }
Example #11
0
 public static function getLoader()
 {
     if (null !== static::$loader) {
         return static::$loader;
     }
     spl_autoload_register(array('ComposerAutoloaderInit121888b6576d33d04a56c26dfb765109', 'loadClassLoader'));
     static::$loader = $loader = new \Composer\Autoload\ClassLoader();
     spl_autoload_unregister(array('ComposerAutoloaderInit121888b6576d33d04a56c26dfb765109', 'loadClassLoader'));
     $vendorDir = dirname(__DIR__);
     $baseDir = dirname($vendorDir);
     $map = (require __DIR__ . '/autoload_namespaces.php');
     foreach ($map as $namespace => $path) {
         $loader->add($namespace, $path);
     }
     //var_dump($loader);
     $classMap = (require __DIR__ . '/autoload_classmap.php');
     if ($classMap) {
         $loader->addClassMap($classMap);
     }
     $loader->register();
     return $loader;
 }
Example #12
0
 public static function getLoader()
 {
     if (null !== static::$loader) {
         return static::$loader;
     }
     static::$loader = $loader = new \Composer\Autoload\ClassLoader();
     $vendorDir = dirname(__DIR__);
     $baseDir = dirname($vendorDir);
     $includePaths = (require __DIR__ . '/include_paths.php');
     array_push($includePaths, get_include_path());
     set_include_path(join(PATH_SEPARATOR, $includePaths));
     $map = (require __DIR__ . '/autoload_namespaces.php');
     foreach ($map as $namespace => $path) {
         $loader->add($namespace, $path);
     }
     $classMap = (require __DIR__ . '/autoload_classmap.php');
     if ($classMap) {
         $loader->addClassMap($classMap);
     }
     $loader->register();
     return $loader;
 }
Example #13
0
 public function __construct()
 {
     global $autoloader;
     parent::__construct();
     static::$loader = $autoloader;
     require __DIR__ . '/version.php';
     // Connect to the database
     $db = $this->config['db'][$this->config['environment']];
     // $GLOBALS['db'] = DriverManager::getConnection([
     $GLOBALS['db'] = ConnectionManager::create(['dbname' => $db['database'], 'user' => $db['username'], 'password' => $db['password'], 'host' => $db['host'], 'driver' => $db['driver'], 'prefix' => $db['prefix']]);
     define('PREFIX', $db['prefix']);
     unset($db);
     // Alias some commonly used classes
     class_alias('Avalon\\Templating\\View', 'View');
     class_alias('Avalon\\Http\\Request', 'Request');
     class_alias('Avalon\\Hook', 'Hook');
     class_alias('Traq\\Helpers\\Errors', 'Errors');
     class_alias('Traq\\Helpers\\Format', 'Format');
     class_alias('Traq\\Helpers\\Ticketlist', 'Ticketlist');
     class_alias('Traq\\Helpers\\TicketFilters', 'TicketFilters');
     class_alias('Avalon\\Helpers\\HTML', 'HTML');
     class_alias('Avalon\\Helpers\\Form', 'Form');
     class_alias('Avalon\\Helpers\\TWBS', 'TWBS');
     class_alias('Avalon\\Helpers\\Gravatar', 'Gravatar');
     // Load commonly used functions
     require __DIR__ . '/common.php';
     View::loadFunctions();
     // If a theme is set, prepend it's views directory
     if (setting('theme') !== 'default') {
         View::addPath(__DIR__ . '/../' . setting('theme') . '/views', true);
     }
     $this->loadTranslations();
     $this->loadPlugins();
     // Set mailer config
     if (isset($this->config['email'])) {
         Notification::setConfig($this->config['email']);
     }
 }
Example #14
0
 public static function getLoader()
 {
     if (null !== static::$loader) {
         return static::$loader;
     }
     spl_autoload_register(array('ComposerAutoloaderInit93f1e84b83781b432268394c32fb013f', 'loadClassLoader'));
     static::$loader = $loader = new \Composer\Autoload\ClassLoader();
     spl_autoload_unregister(array('ComposerAutoloaderInit93f1e84b83781b432268394c32fb013f', 'loadClassLoader'));
     $vendorDir = dirname(__DIR__);
     $baseDir = dirname($vendorDir);
     $map = (require __DIR__ . '/autoload_namespaces.php');
     foreach ($map as $namespace => $path) {
         $loader->add($namespace, $path);
     }
     $classMap = (require __DIR__ . '/autoload_classmap.php');
     if ($classMap) {
         $loader->addClassMap($classMap);
     }
     $loader->register();
     require $vendorDir . '/swiftmailer/swiftmailer/lib/swift_required.php';
     require $vendorDir . '/kriswallsmith/assetic/src/functions.php';
     return $loader;
 }
 /**
  * Renderer initialisieren
  */
 private static function init()
 {
     // Loader nur einmal pro Skriptlaufzeit erstellen
     if (is_null(static::$loader)) {
         // Autoloader der Renderers aktivieren
         Twig_Autoloader::register();
         // Basisverzeichnis des Renderers zuweisen
         static::$loader = new Twig_Loader_Filesystem(DIR_TEMPLATES);
         // UMGEBUNGS-EINSTELLUNGEN DES RENDERERS SETZEN
         $twigSettings = array('cache' => DIR_COMPILED);
         if (static::DEBUG) {
             $twigSettings['debug'] = true;
             // dump()-Methode zur Verfügung stellen
             $twigSettings['auto_reload'] = true;
             // Bei Templateänderungen sofort neu kompilieren
         }
         static::$twig = new Twig_Environment(static::$loader, $twigSettings);
         // dump()-Methode zur Verfügung stellen
         if (static::DEBUG) {
             static::$twig->addExtension(new Twig_Extension_Debug());
         }
         // EIGENE METHODEN FUER RENDERER ZUWEISEN
         $renderUrl = new Twig_SimpleFunction('url', array('Renderer', 'renderUrl'));
         static::$twig->addFunction($renderUrl);
         $renderPrice = new Twig_SimpleFunction('price', array('Renderer', 'renderPrice'), array('is_safe' => array('html')));
         static::$twig->addFunction($renderPrice);
         $renderLimitUnit = new Twig_SimpleFunction('unit', array('Renderer', 'renderLimitUnit'), array('is_safe' => array('html')));
         static::$twig->addFunction($renderLimitUnit);
         $formatNumber = new Twig_SimpleFunction('formatNumber', array('Renderer', 'formatNumber'));
         static::$twig->addFunction($formatNumber);
         $markError = new Twig_SimpleFunction('markError', array('Renderer', 'markError'));
         static::$twig->addFunction($markError);
         $getError = new Twig_SimpleFunction('getError', array('Renderer', 'getError'));
         static::$twig->addFunction($getError);
     }
 }
Example #16
0
 protected static function _setLoader($loader)
 {
     static::$loader = $loader;
 }
Example #17
0
 public function __construct($path = null, $options = [])
 {
     static::$templatePath = rtrim($path, '/') . '/';
     static::$loader = new \Twig_Loader_Filesystem($path);
     static::$twig = new \Twig_Environment(static::$loader, $options);
 }
 public function setUp()
 {
     parent::setUp();
     static::$routeRedirectRepo = self::$staticContainer->get('s.mantle.route_redirect.repo');
     static::$loader = new RouteRedirectLoader(static::$routeRedirectRepo);
 }
Example #19
0
 /**
  * Creates a new loader
  *
  * @return DI
  * @author Dan Cox
  */
 public function make()
 {
     static::$loader = new YamlFileLoader(static::$container, new FileLocator($this->directory));
     return $this;
 }
Example #20
0
 /**
  * 注册自动加载器
  */
 public function registerAutoloader($path = null)
 {
     if (is_null(static::$loader)) {
         require __DIR__ . DIRECTORY_SEPARATOR . 'Loader.php';
         $loader = new Loader();
         $loader->register();
         $loader->addClassMap(require __DIR__ . DIRECTORY_SEPARATOR . 'classmap.php');
         // 注册文件夹
         if (is_dir($path)) {
             $loader->add(null, $path);
         }
         static::$loader = $loader;
     }
     return static::$loader;
 }
Example #21
0
 /**
  * Registers the auto loader to use
  * @static
  * @param AutoLoaderInterface $loader
  */
 public static function register(AutoLoaderInterface $loader)
 {
     static::$loader = $loader;
     static::$loader->register();
 }
Example #22
0
File: Text.php Project: yunaid/yf
 /**
  * Set loader
  * @param Lodaer $loader
  */
 public static function loader($loader)
 {
     static::$loader = $loader;
 }
Example #23
0
 /**
  * Builds the DI container
  *
  * @return DI
  * @author Dan Cox
  */
 public function build()
 {
     // We must have a directory set;
     if (is_null($this->directory)) {
         throw new Exceptions\DI\InvalidServiceDirectory($this);
     }
     // Load extensions, if there are any
     $this->loadExtensions();
     // This just builds the components, ready to load a service definition file
     static::$loader = new YamlFileLoader(static::$container, new FileLocator($this->directory));
     return $this;
 }