本文整理汇总了PHP中Symfony\Component\ClassLoader\UniversalClassLoader类的典型用法代码示例。如果您正苦于以下问题:PHP UniversalClassLoader类的具体用法?PHP UniversalClassLoader怎么用?PHP UniversalClassLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UniversalClassLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sf2AutoLoad
function sf2AutoLoad()
{
$loader = new UniversalClassLoader();
$loader->registerNamespaces(array('Sf2Plugins' => __DIR__ . '/src'));
$loader->registerPrefixes(array('Twig_Extensions_' => __DIR__ . '/lib/Twig-extensions/lib', 'Twig_' => __DIR__ . '/lib/Twig/lib'));
$loader->register();
}
示例2: earlyInitialize
public static function earlyInitialize()
{
$classLoader = new UniversalClassLoader();
$classLoader->registerNamespace('Stagehand\\TestRunner', array(__DIR__ . '/../../..', __DIR__ . '/../../../../src/Stagehand/TestRunner/Resources/examples'));
$classLoader->registerPrefix('Stagehand_TestRunner_', __DIR__ . '/../../../../src/Stagehand/TestRunner/Resources/examples');
$classLoader->register();
}
示例3: __construct
/**
* Constructor.
*/
public function __construct()
{
$app = $this;
$this['autoloader'] = $this->share(function () {
$loader = new UniversalClassLoader();
$loader->register();
return $loader;
});
$this['routes'] = $this->share(function () {
return new RouteCollection();
});
$this['controllers'] = $this->share(function () use($app) {
return new ControllerCollection($app['routes']);
});
$this['dispatcher'] = $this->share(function () use($app) {
$dispatcher = new EventDispatcher();
$dispatcher->addSubscriber($app);
return $dispatcher;
});
$this['resolver'] = $this->share(function () {
return new ControllerResolver();
});
$this['kernel'] = $this->share(function () use($app) {
return new HttpKernel($app['dispatcher'], $app['resolver']);
});
$this['request.http_port'] = 80;
$this['request.https_port'] = 443;
}
示例4: testLegacyHandleClassNotFound
/**
* @group legacy
*/
public function testLegacyHandleClassNotFound()
{
$prefixes = array('Symfony\\Component\\Debug\\Exception\\' => realpath(__DIR__ . '/../../Exception'));
$symfonyUniversalClassLoader = new SymfonyUniversalClassLoader();
$symfonyUniversalClassLoader->registerPrefixes($prefixes);
$this->testHandleClassNotFound(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), "Attempted to load class \"UndefinedFunctionException\" from namespace \"Foo\\Bar\".\nDid you forget a \"use\" statement for \"Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException\"?", array($symfonyUniversalClassLoader, 'loadClass'));
}
示例5: testLoadClassPrefixCollision
/**
* @dataProvider getLoadClassPrefixCollisionTests
*/
public function testLoadClassPrefixCollision($prefixes, $className, $message)
{
$loader = new UniversalClassLoader();
$loader->registerPrefixes($prefixes);
$loader->loadClass($className);
$this->assertTrue(class_exists($className), $message);
}
示例6: __construct
/**
* Constructor
*
* @param KernelInterface $kernel
*/
public function __construct(KernelInterface $kernel)
{
// register email address proxy class loader
$loader = new UniversalClassLoader();
$loader->registerNamespaces([self::ENTITY_PROXY_NAMESPACE => $kernel->getCacheDir() . DIRECTORY_SEPARATOR . self::CACHED_ENTITIES_DIR_NAME]);
$loader->register();
}
示例7: registerBundles
public function registerBundles()
{
$loader = new UniversalClassLoader();
$loader->registerNamespace('SomeProject\\', array(__DIR__));
$loader->registerNamespace('SomeAnotherProject\\', array(__DIR__));
$loader->register();
return array(new \SomeProject\Bundle\SomeBundle\SomeBundle(), new \SomeAnotherProject\Bundle\SomeAnotherBundle\SomeAnotherBundle());
}
示例8: __construct
/**
* Constructor.
*/
public function __construct()
{
$app = $this;
$this['autoloader'] = $this->share(function () {
$loader = new UniversalClassLoader();
$loader->register();
return $loader;
});
$this['debug'] = false;
$this['charset'] = 'UTF-8';
}
示例9: provideLegacyClassNotFoundData
public function provideLegacyClassNotFoundData()
{
$prefixes = array('Symfony\\Component\\Debug\\Exception\\' => realpath(__DIR__ . '/../../Exception'));
$symfonyAutoloader = new SymfonyClassLoader();
$symfonyAutoloader->addPrefixes($prefixes);
$symfonyUniversalClassLoader = new SymfonyUniversalClassLoader();
$symfonyUniversalClassLoader->registerPrefixes($prefixes);
return array(array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), "Attempted to load class \"UndefinedFunctionException\" from namespace \"Foo\\Bar\".\nDid you forget a \"use\" statement for \"Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException\"?", array($symfonyAutoloader, 'loadClass')), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), "Attempted to load class \"UndefinedFunctionException\" from namespace \"Foo\\Bar\".\nDid you forget a \"use\" statement for \"Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException\"?", array($symfonyUniversalClassLoader, 'loadClass')), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), "Attempted to load class \"UndefinedFunctionException\" from namespace \"Foo\\Bar\".\nDid you forget a \"use\" statement for another namespace?", function ($className) {
/* do nothing here */
}));
}
示例10: provideClassNotFoundData
public function provideClassNotFoundData()
{
$prefixes = array('Symfony\\Component\\Debug\\Exception\\' => realpath(__DIR__ . '/../../Exception'));
$symfonyAutoloader = new SymfonyClassLoader();
$symfonyAutoloader->addPrefixes($prefixes);
$symfonyUniversalClassLoader = new SymfonyUniversalClassLoader();
$symfonyUniversalClassLoader->registerPrefixes($prefixes);
return array(array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'WhizBangFactory\' not found'), 'Attempted to load class "WhizBangFactory" from the global namespace in foo.php line 12. Did you forget a use statement for this class?'), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\WhizBangFactory\' not found'), 'Attempted to load class "WhizBangFactory" from namespace "Foo\\Bar" in foo.php line 12. Do you need to "use" it from another namespace?'), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'UndefinedFunctionException\' not found'), 'Attempted to load class "UndefinedFunctionException" from the global namespace in foo.php line 12. Did you forget a use statement for this class? Perhaps you need to add a use statement for one of the following: Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException.'), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'PEARClass\' not found'), 'Attempted to load class "PEARClass" from the global namespace in foo.php line 12. Did you forget a use statement for this class? Perhaps you need to add a use statement for one of the following: Symfony_Component_Debug_Tests_Fixtures_PEARClass.'), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), 'Attempted to load class "UndefinedFunctionException" from namespace "Foo\\Bar" in foo.php line 12. Do you need to "use" it from another namespace? Perhaps you need to add a use statement for one of the following: Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException.'), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), 'Attempted to load class "UndefinedFunctionException" from namespace "Foo\\Bar" in foo.php line 12. Do you need to "use" it from another namespace? Perhaps you need to add a use statement for one of the following: Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException.', array($symfonyAutoloader, 'loadClass')), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), 'Attempted to load class "UndefinedFunctionException" from namespace "Foo\\Bar" in foo.php line 12. Do you need to "use" it from another namespace? Perhaps you need to add a use statement for one of the following: Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException.', array($symfonyUniversalClassLoader, 'loadClass')), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), 'Attempted to load class "UndefinedFunctionException" from namespace "Foo\\Bar" in foo.php line 12. Do you need to "use" it from another namespace?', function ($className) {
/* do nothing here */
}));
}
示例11: __construct
public function __construct()
{
$app = $this;
$this['autoloader'] = $this->share(function () {
$loader = new UniversalClassLoader();
$loader->register();
return $loader;
});
$this['basedir'] = __DIR__ . '/../../../..';
$this->register_twig();
$this->register_markdown();
}
示例12: checkComposer
/**
* Check for composer in Namespace
* and include via phar if possible
*/
public static function checkComposer($pathToComposer = null)
{
if (!class_exists("Composer\\Factory")) {
if (false === ($pathToComposer = self::whichComposer($pathToComposer))) {
throw new \RuntimeException("Could not find composer.phar");
}
\Phar::loadPhar($pathToComposer, 'composer.phar');
$loader = new UniversalClassLoader();
$namespaces = (include "phar://composer.phar/vendor/composer/autoload_namespaces.php");
$loader->registerNamespaces(array_merge(array('Composer' => "phar://composer.phar/src/"), $namespaces));
$loader->register(true);
}
}
示例13: __construct
/**
* Constructor.
*/
public function __construct()
{
$app = $this;
$this['autoloader'] = $this->share(function () {
$loader = new UniversalClassLoader();
$loader->register();
return $loader;
});
$this['routes'] = $this->share(function () {
return new RouteCollection();
});
$this['controllers'] = $this->share(function () use($app) {
return new ControllerCollection();
});
$this['exception_handler'] = $this->share(function () {
return new ExceptionHandler();
});
$this['dispatcher'] = $this->share(function () use($app) {
$dispatcher = new EventDispatcher();
$dispatcher->addSubscriber($app);
$urlMatcher = new LazyUrlMatcher(function () use($app) {
return $app['url_matcher'];
});
$dispatcher->addSubscriber(new RouterListener($urlMatcher));
return $dispatcher;
});
$this['resolver'] = $this->share(function () use($app) {
return new ControllerResolver($app);
});
$this['kernel'] = $this->share(function () use($app) {
return new HttpKernel($app['dispatcher'], $app['resolver']);
});
$this['request_context'] = $this->share(function () use($app) {
$context = new RequestContext();
$context->setHttpPort($app['request.http_port']);
$context->setHttpsPort($app['request.https_port']);
return $context;
});
$this['url_matcher'] = $this->share(function () use($app) {
return new RedirectableUrlMatcher($app['routes'], $app['request_context']);
});
$this['request.default_locale'] = 'en';
$this['request'] = function () {
throw new \RuntimeException('Accessed request service outside of request scope. Try moving that call to a before handler or controller.');
};
$this['request.http_port'] = 80;
$this['request.https_port'] = 443;
$this['debug'] = false;
$this['charset'] = 'UTF-8';
}
示例14: configureClassLoader
protected function configureClassLoader()
{
if (!class_exists('Stagehand\\TestRunner\\Core\\Environment')) {
if (!class_exists('Symfony\\Component\\ClassLoader\\UniversalClassLoader', false)) {
require_once 'Symfony/Component/ClassLoader/UniversalClassLoader.php';
}
$includePaths = explode(PATH_SEPARATOR, get_include_path());
$classLoader = new UniversalClassLoader();
foreach (self::$namespaces as $namespace) {
$classLoader->registerNamespace($namespace, $includePaths);
}
$classLoader->register();
}
}
示例15: initialize
/**
* Initialise.
*
* Runs at plugin init time.
*
* @return void
*/
public function initialize(GenericEvent $event)
{
// register namespace
// Because the standard kernel classloader already has Doctrine registered as a namespace
// we have to add a new loader onto the spl stack.
$autoloader = new UniversalClassLoader();
$autoloader->register();
$autoloader->registerNamespaces(array('DoctrineProxy' => 'ztemp/doctrinemodels'));
$container = $event->getDispatcher()->getContainer();
$config = $GLOBALS['ZConfig']['DBInfo']['databases']['default'];
$dbConfig = array('host' => $config['host'], 'user' => $config['user'], 'password' => $config['password'], 'dbname' => $config['dbname'], 'driver' => 'pdo_' . $config['dbdriver']);
$r = new \ReflectionClass('Doctrine\\Common\\Cache\\' . $container['dbcache.type'] . 'Cache');
$dbCache = $r->newInstance();
$ORMConfig = new \Doctrine\ORM\Configuration();
$container->set('doctrine.configuration', $ORMConfig);
$ORMConfig->setMetadataCacheImpl($dbCache);
// create proxy cache dir
\CacheUtil::createLocalDir('doctrinemodels');
// setup annotations base
include_once \ZLOADER_PATH . '/../vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php';
// setup annotation reader
$reader = new \Doctrine\Common\Annotations\AnnotationReader();
$cacheReader = new \Doctrine\Common\Annotations\CachedReader($reader, new \Doctrine\Common\Cache\ArrayCache());
$container->set('doctrine.annotationreader', $cacheReader);
// setup annotation driver
$annotationDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($cacheReader);
$container->set('doctrine.annotationdriver', $annotationDriver);
// setup driver chains
$driverChain = new \Doctrine\ORM\Mapping\Driver\DriverChain();
$container->set('doctrine.driverchain', $driverChain);
// configure Doctrine ORM
$ORMConfig->setMetadataDriverImpl($annotationDriver);
$ORMConfig->setQueryCacheImpl($dbCache);
$ORMConfig->setProxyDir(\CacheUtil::getLocalDir('doctrinemodels'));
$ORMConfig->setProxyNamespace('DoctrineProxy');
if (isset($container['log.enabled']) && $container['log.enabled']) {
$ORMConfig->setSQLLogger(new \Zikula\Core\Doctrine\Logger\ZikulaSqlLogger());
}
// setup doctrine eventmanager
$dispatcher = new \Doctrine\Common\EventManager();
$container->set('doctrine.eventmanager', $dispatcher);
// setup MySQL specific listener (storage engine and encoding)
if ($config['dbdriver'] == 'mysql') {
$mysqlSessionInit = new \Doctrine\DBAL\Event\Listeners\MysqlSessionInit($config['charset']);
$dispatcher->addEventSubscriber($mysqlSessionInit);
}
// setup the doctrine entitymanager
$entityManager = \Doctrine\ORM\EntityManager::create($dbConfig, $ORMConfig, $dispatcher);
$container->set('doctrine.entitymanager', $entityManager);
}