当前位置: 首页>>代码示例>>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;未经允许,请勿转载。