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


PHP ClassLoader::getPrefixes方法代碼示例

本文整理匯總了PHP中Composer\Autoload\ClassLoader::getPrefixes方法的典型用法代碼示例。如果您正苦於以下問題:PHP ClassLoader::getPrefixes方法的具體用法?PHP ClassLoader::getPrefixes怎麽用?PHP ClassLoader::getPrefixes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Composer\Autoload\ClassLoader的用法示例。


在下文中一共展示了ClassLoader::getPrefixes方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 /**
  * Constructs an wrapper for the composer loader
  *
  * @param ClassLoader $original Instance of current loader
  * @param AspectContainer $container Instance of the container
  * @param array $options Configuration options
  */
 public function __construct(ClassLoader $original, AspectContainer $container, array $options = [])
 {
     $this->options = $options;
     $this->original = $original;
     $prefixes = $original->getPrefixes();
     $excludePaths = $options['excludePaths'];
     // Let's exclude core dependencies from that list
     $excludePaths[] = $prefixes['Dissect'][0];
     $excludePaths[] = substr($prefixes['Doctrine\\Common\\Annotations\\'][0], 0, -16);
     $fileEnumerator = new Enumerator($options['appDir'], $options['includePaths'], $excludePaths);
     $this->fileEnumerator = $fileEnumerator;
     $this->cacheState = $container->get('aspect.cache.path.manager')->queryCacheState();
 }
開發者ID:unknownnf,項目名稱:framework,代碼行數:20,代碼來源:AopComposerLoader.php

示例2: __construct

 public function __construct(ClassLoader $loader, Engine $engine = null)
 {
     if (!$engine) {
         $engine = new Engine();
     }
     $this->engine = $engine;
     $this->add(null, $loader->getFallbackDirs());
     $this->addPsr4(null, $loader->getFallbackDirsPsr4());
     foreach ($loader->getPrefixes() as $prefix => $path) {
         $this->add($prefix, $path);
     }
     foreach ($loader->getPrefixesPsr4() as $prefix => $path) {
         $this->addPsr4($prefix, $path);
     }
     $this->setUseIncludePath($loader->getUseIncludePath());
 }
開發者ID:killer100,項目名稱:PhpGenerics,代碼行數:16,代碼來源:Autoloader.php

示例3: getConfig

 /**
  * {@inheritdoc}
  */
 public function getConfig()
 {
     // Initialize empty configuration.
     $config = ['psr-0' => [], 'psr-4' => [], 'class-location' => []];
     // Find the tokenized paths.
     $psrs = array('psr-0' => $this->classLoader->getPrefixes(), 'psr-4' => $this->classLoader->getPrefixesPsr4());
     // Get all the PSR-0 and PSR-0 and detect the ones that have Drupal tokens.
     foreach ($psrs as $psr_type => $namespaces) {
         $namespaces = $namespaces ?: [];
         foreach ($namespaces as $prefix => $paths) {
             $token_paths = array();
             if (!is_array($paths)) {
                 $paths = array($paths);
             }
             foreach ($paths as $path) {
                 $token_resolver = $this->tokenFactory->factory($path);
                 if (!$token_resolver->hasToken()) {
                     continue;
                 }
                 $path = $token_resolver->trimPath();
                 $token_paths[] = $path;
             }
             // If there were paths, add them to the config.
             if (!empty($token_paths)) {
                 $config[$psr_type][$prefix] = $token_paths;
             }
         }
     }
     // Get the drupal path configuration.
     $composer_config = json_decode(file_get_contents(static::COMPOSER_CONFIGURATION_NAME));
     $config['class-location'] = array();
     if (isset($composer_config->autoload->{'class-location'})) {
         $config['class-location'] = array_merge($config['class-location'], (array) $composer_config->autoload->{'class-location'});
     }
     if (isset($composer_config->{'autoload-dev'}->{'class-location'})) {
         $config['class-location'] = array_merge($config['class-location'], (array) $composer_config->{'autoload-dev'}->{'class-location'});
     }
     return $config;
 }
開發者ID:e0ipso,項目名稱:drupal-unit-autoload,代碼行數:42,代碼來源:AutoloaderBootstrap.php

示例4: add

 public static function add($namespace, $dir)
 {
     if (!in_array($namespace, self::$autoloader->getPrefixes())) {
         self::$autoloader->add($namespace, dirname($dir));
     }
 }
開發者ID:rtznprmpftl,項目名稱:Zikulacore,代碼行數:6,代碼來源:ZikulaAutoload.php

示例5: testGetPrefixesWithNoPSR0Configuration

 /**
  * getPrefixes method should return empty array if ClassLoader does not have any psr-0 configuration
  */
 public function testGetPrefixesWithNoPSR0Configuration()
 {
     $loader = new ClassLoader();
     $this->assertEmpty($loader->getPrefixes());
 }
開發者ID:alancleaver,項目名稱:composer,代碼行數:8,代碼來源:ClassLoaderTest.php

示例6: add

 public function add($prefix, $path, $prepend = false)
 {
     $this->mainLoader->add($prefix, $path, $prepend);
     $this->prefixes = array_merge($this->prefixes, $this->mainLoader->getPrefixes());
     return $this;
 }
開發者ID:phpguard,項目名稱:phpguard,代碼行數:6,代碼來源:Locator.php


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