本文整理汇总了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();
}
示例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());
}
示例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;
}
示例4: add
public static function add($namespace, $dir)
{
if (!in_array($namespace, self::$autoloader->getPrefixes())) {
self::$autoloader->add($namespace, dirname($dir));
}
}
示例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());
}
示例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;
}