當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ClassLoader\UniversalClassLoader類代碼示例

本文整理匯總了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();
}
開發者ID:nunnun,項目名稱:wp-sf2,代碼行數:7,代碼來源:wp-sf2.php

示例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();
 }
開發者ID:ngyuki,項目名稱:stagehand-testrunner,代碼行數:7,代碼來源:TestEnvironment.php

示例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;
 }
開發者ID:NoDiskInDriveA,項目名稱:Silex,代碼行數:31,代碼來源:Application.php

示例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'));
 }
開發者ID:ngitimfoyo,項目名稱:Nyari-AppPHP,代碼行數:10,代碼來源:ClassNotFoundFatalErrorHandlerTest.php

示例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);
 }
開發者ID:robertowest,項目名稱:CuteFlow-V4,代碼行數:10,代碼來源:UniversalClassLoaderTest.php

示例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();
 }
開發者ID:xamin123,項目名稱:platform,代碼行數:12,代碼來源:OroEmailBundle.php

示例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());
 }
開發者ID:Maksold,項目名稱:platform,代碼行數:8,代碼來源:TestKernel.php

示例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';
 }
開發者ID:nubeiro,項目名稱:LogMonitor,代碼行數:14,代碼來源:LogSpyApp.php

示例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 */
     }));
 }
開發者ID:EnmanuelCode,項目名稱:backend-laravel,代碼行數:11,代碼來源:ClassNotFoundFatalErrorHandlerTest.php

示例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 */
     }));
 }
開發者ID:roberto-sanchez,項目名稱:gardencentral,代碼行數:11,代碼來源:ClassNotFoundFatalErrorHandlerTest.php

示例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();
 }
開發者ID:nacmartin,項目名稱:Cazalla,代碼行數:12,代碼來源:Application.php

示例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);
     }
 }
開發者ID:Viduc,項目名稱:tiremoidlaold,代碼行數:17,代碼來源:ComposerAdapter.php

示例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';
 }
開發者ID:noels,項目名稱:Silex,代碼行數:53,代碼來源:Application.php

示例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();
     }
 }
開發者ID:ngyuki,項目名稱:stagehand-testrunner,代碼行數:14,代碼來源:Bootstrap.php

示例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);
 }
開發者ID:planetenkiller,項目名稱:core,代碼行數:57,代碼來源:DoctrineListener.php


注:本文中的Symfony\Component\ClassLoader\UniversalClassLoader類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。