示例#1
0
 /**
  * Calls all init functions of the WCF class.
  */
 public function __construct()
 {
     // add autoload directory
     self::$autoloadDirectories['wcf'] = WCF_DIR . 'lib/';
     // define tmp directory
     if (!defined('TMP_DIR')) {
         define('TMP_DIR', FileUtil::getTempFolder());
     }
     // register additional autoloaders
     require_once WCF_DIR . 'lib/system/api/phpline/phpline.phar';
     require_once WCF_DIR . 'lib/system/api/zend/Loader/StandardAutoloader.php';
     $zendLoader = new ZendLoader(array(ZendLoader::AUTOREGISTER_ZF => true));
     $zendLoader->register();
     $argv = new ArgvParser(array('packageID=i' => ''));
     $argv->setOption(ArgvParser::CONFIG_FREEFORM_FLAGS, true);
     $argv->parse();
     define('PACKAGE_ID', $argv->packageID ?: 1);
     // disable benchmark
     define('ENABLE_BENCHMARK', 0);
     // start initialization
     $this->initDB();
     $this->loadOptions();
     $this->initSession();
     $this->initLanguage();
     $this->initTPL();
     $this->initCoreObjects();
     $this->initApplications();
     // the destructor registered in core.functions.php will only call the destructor of the parent class
     register_shutdown_function(array('wcf\\system\\CLIWCF', 'destruct'));
     $this->initArgv();
     $this->initPHPLine();
     $this->initAuth();
     $this->checkForUpdates();
     $this->initCommands();
 }
示例#2
0
 public static function register()
 {
     /**
      * Register ModSync namespace
      */
     $autoLoader = new Zend\Loader\StandardAutoloader(array('autoregister_zf' => true));
     $autoLoader->registerNamespace('ModSync', Base::getCoreComponentsDir() . DIRECTORY_SEPARATOR . __NAMESPACE__);
     $autoLoader->register();
     /**
      * Register all other namespaces
      */
     $components = new DirectoryIterator(Base::getCoreComponentsDir());
     foreach ($components as $component) {
         if ($component->isDot()) {
             continue;
         }
         if ($component->getFilename() == 'ModSync') {
             continue;
         }
         $componentFile = new SplFileInfo($component->getPathname() . DIRECTORY_SEPARATOR . 'Component' . DIRECTORY_SEPARATOR . 'Component.php');
         if ($componentFile->isFile()) {
             $autoLoader->registerNamespace($component->getFilename(), $component->getPathname());
         }
     }
 }
示例#3
0
 /**
  * Constructor
  *
  * Initialize application. Potentially initializes include_paths, PHP
  * settings, and bootstrap class.
  *
  * @param  string                   $environment
  * @param  string|array|Traversable $options String path to configuration file, or array/Traversable of configuration options
  * @throws Exception When invalid options are provided
  * @return void
  */
 public function __construct($environment, $options = null)
 {
     $this->_environment = (string) $environment;
     /**
      * @todo Make this configurable?
      */
     if (file_exists(__DIR__ . '/../../../../../library/Zend/Loader/StandardAutoloader.php')) {
         require_once __DIR__ . '/../../../../../library/Zend/Loader/StandardAutoloader.php';
     } else {
         require_once 'Zend/Loader/StandardAutoloader.php';
     }
     $autoloader = new StandardAutoloader();
     $autoloader->register();
     $this->setAutoloader($autoloader);
     if (null !== $options) {
         if (is_string($options)) {
             $options = $this->_loadConfig($options);
         } elseif ($options instanceof Traversable) {
             $options = ArrayUtils::iteratorToArray($options);
         } elseif (!is_array($options)) {
             throw new Exception\InvalidArgumentException('Invalid options provided; must be location of config file, a config object, or an array');
         }
         $this->setOptions($options);
     }
 }
if (!is_dir($libPath)) {
    // Try to load StandardAutoloader from include_path
    if (false === (include 'Zend/Loader/StandardAutoloader.php')) {
        echo "Unable to locate autoloader via include_path; aborting" . PHP_EOL;
        exit(2);
    }
} else {
    // Try to load StandardAutoloader from library
    if (false === (include $libPath . '/Zend/Loader/StandardAutoloader.php')) {
        echo "Unable to locate autoloader via library; aborting" . PHP_EOL;
        exit(2);
    }
}
// Setup autoloading
$loader = new StandardAutoloader(array('autoregister_zf' => true));
$loader->register();
$rules = array('help|h' => 'Get usage message', 'library|l-s' => 'Library to parse; if none provided, assumes current directory', 'output|o-s' => 'Where to write plugin map file; if not provided, assumes "plugin_classmap.php" in library directory', 'append|a' => 'Append to plugin map file if it exists', 'overwrite|w' => 'Whether or not to overwrite existing autoload file');
try {
    $opts = new Console\Getopt($rules);
    $opts->parse();
} catch (Console\Exception\RuntimeException $e) {
    echo $e->getUsageMessage();
    exit(2);
}
if ($opts->getOption('h')) {
    echo $opts->getUsageMessage();
    exit;
}
$path = $libPath;
if (array_key_exists('PWD', $_SERVER)) {
    $path = $_SERVER['PWD'];
 public function testRegisterRegistersCallbackWithSplAutoload()
 {
     $loader = new StandardAutoloader();
     $loader->register();
     $loaders = spl_autoload_functions();
     $this->assertTrue(count($this->loaders) < count($loaders));
     $test = array_pop($loaders);
     $this->assertEquals(array($loader, 'autoload'), $test);
 }
<?php

define("__FORM__", "Application\\Form\\Type\\");
define("__ENTITY__", "Application\\Model\\Entity\\");
use Silex\Application;
use Zend\Loader\StandardAutoloader;
use Zend\Loader\ClassMapAutoloader;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Loader\YamlFileLoader;
$standarAutoloader = new StandardAutoloader();
$classmapAutoloader = new ClassMapAutoloader();
$standarAutoloader->registerNamespaces(array('Application\\' => __DIR__ . '/../'));
$classmapAutoloader->registerAutoloadMap(array('PHPExcel' => __DIR__ . '/../../lib/excel/PHPExcel.php', 'PHPMailer' => __DIR__ . '/../../lib/mailer/phpmailer.php', 'SMTP' => __DIR__ . '/../../lib/mailer/class.smtp.php', 'vcalendar' => __DIR__ . '/../../lib/calendar/ical/iCalcreator.class.php'));
$standarAutoloader->register();
$classmapAutoloader->register();
$app["debug"] = true;
$c = new \vcalendar(array('unique_id' => $_SERVER['HTTP_HOST']));
$t =& $c->newComponent('vtodo');
$t->setProperty('dtstart', '19970415T133000 GMT');
$t->setProperty('due', '19970416T045959 GMT');
$t->setProperty('summary', '1996 Income Tax Preparation');
$t->setProperty('class', 'CONFIDENTIAL');
$t->setProperty('categories', 'FAMILY');
$t->setProperty('categories', 'FINANCE');
$t->setProperty('priority', 1);
$t->setProperty('status', 'NEEDS-ACTION');
$str = $c->createCalendar();
$calendarPath = __DIR__ . '/../tmp/Calendar';
file_put_contents($calendarPath . '/sample.ics', $str);
//echo $str;
 /**
  * @param string $namespace
  * @param string $namespaceDirectory
  */
 protected function registerEntityFilesNamespace($namespace, $namespaceDirectory)
 {
     $loader = new StandardAutoloader();
     $loader->registerNamespace($namespace, $namespaceDirectory);
     $loader->register();
 }
示例#8
0
<?php

/**
 * This makes our life easier when dealing with paths. Everything is relative
 * to the application root now.
 */
chdir(dirname(__DIR__));
// Setup autoloading
require 'vendor/autoload.php';
require 'module/Debug.php';
use Zend\Loader\StandardAutoloader;
$autoloader = new StandardAutoloader();
$autoloader->registerNamespace('ApplicationTest', __DIR__ . '/ApplicationTest/');
$autoloader->registerNamespace('TheodiaTest', __DIR__ . '/TheodiaTest/');
$autoloader->register();
// All tests always execute with a mocked 'now' time
$myClassReflection = new \ReflectionClass(Application\Utility::class);
$nowProperty = $myClassReflection->getProperty('now');
$nowProperty->setAccessible(true);
$nowProperty->setValue(null, new \DateTimeImmutable('2015-01-02T03:04:00', new \DateTimeZone('UTC')));