当前位置: 首页>>代码示例>>PHP>>正文


PHP ClassLoader::addPsr4方法代码示例

本文整理汇总了PHP中Composer\Autoload\ClassLoader::addPsr4方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassLoader::addPsr4方法的具体用法?PHP ClassLoader::addPsr4怎么用?PHP ClassLoader::addPsr4使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Composer\Autoload\ClassLoader的用法示例。


在下文中一共展示了ClassLoader::addPsr4方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: registerTestNamespaces

 /**
  * Registers test namespaces of all available extensions.
  *
  * @return array
  *   An associative array whose keys are PSR-4 namespace prefixes and whose
  *   values are directory names.
  */
 public function registerTestNamespaces()
 {
     if (isset($this->testNamespaces)) {
         return $this->testNamespaces;
     }
     $this->testNamespaces = array();
     $existing = $this->classLoader->getPrefixesPsr4();
     // Add PHPUnit test namespace of Drupal core.
     $this->testNamespaces['Drupal\\Tests\\'] = [DRUPAL_ROOT . '/core/tests/Drupal/Tests'];
     $this->availableExtensions = array();
     foreach ($this->getExtensions() as $name => $extension) {
         $this->availableExtensions[$extension->getType()][$name] = $name;
         $base_namespace = "Drupal\\{$name}\\";
         $base_path = DRUPAL_ROOT . '/' . $extension->getPath();
         // Add namespace of disabled/uninstalled extensions.
         if (!isset($existing[$base_namespace])) {
             $this->classLoader->addPsr4($base_namespace, "{$base_path}/src");
         }
         // Add Simpletest test namespace.
         $this->testNamespaces[$base_namespace . 'Tests\\'][] = "{$base_path}/src/Tests";
         // Add PHPUnit test namespace.
         // @todo Move PHPUnit namespace of extensions into Drupal\Tests\$name.
         // @see https://www.drupal.org/node/2260121
         $this->testNamespaces[$base_namespace . 'Tests\\'][] = "{$base_path}/tests/src";
     }
     foreach ($this->testNamespaces as $prefix => $paths) {
         $this->classLoader->addPsr4($prefix, $paths);
     }
     return $this->testNamespaces;
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:37,代码来源:TestDiscovery.php

示例2: registerTestNamespaces

 /**
  * Registers test namespaces of all available extensions.
  *
  * @return array
  *   An associative array whose keys are PSR-4 namespace prefixes and whose
  *   values are directory names.
  */
 public function registerTestNamespaces()
 {
     if (isset($this->testNamespaces)) {
         return $this->testNamespaces;
     }
     $this->testNamespaces = array();
     $existing = $this->classLoader->getPrefixesPsr4();
     // Add PHPUnit test namespaces of Drupal core.
     $this->testNamespaces['Drupal\\Tests\\'] = [DRUPAL_ROOT . '/core/tests/Drupal/Tests'];
     $this->testNamespaces['Drupal\\FunctionalTests\\'] = [DRUPAL_ROOT . '/core/tests/Drupal/FunctionalTests'];
     $this->availableExtensions = array();
     foreach ($this->getExtensions() as $name => $extension) {
         $this->availableExtensions[$extension->getType()][$name] = $name;
         $base_path = DRUPAL_ROOT . '/' . $extension->getPath();
         // Add namespace of disabled/uninstalled extensions.
         if (!isset($existing["Drupal\\{$name}\\"])) {
             $this->classLoader->addPsr4("Drupal\\{$name}\\", "{$base_path}/src");
         }
         // Add Simpletest test namespace.
         $this->testNamespaces["Drupal\\{$name}\\Tests\\"][] = "{$base_path}/src/Tests";
         // Add PHPUnit test namespaces.
         $this->testNamespaces["Drupal\\Tests\\{$name}\\Unit\\"][] = "{$base_path}/tests/src/Unit";
         $this->testNamespaces["Drupal\\Tests\\{$name}\\Functional\\"][] = "{$base_path}/tests/src/Functional";
     }
     foreach ($this->testNamespaces as $prefix => $paths) {
         $this->classLoader->addPsr4($prefix, $paths);
     }
     return $this->testNamespaces;
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:36,代码来源:TestDiscovery.php

示例3: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     $classLoader = new ClassLoader();
     $classLoader->addPsr4('App\\', __DIR__ . '/Fixtures/src/App');
     $classLoader->addPsr4('Test\\', __DIR__ . '/Fixtures/src/Test');
     $classLoader->register();
 }
开发者ID:radphp,项目名称:radphp,代码行数:7,代码来源:EtcTest.php

示例4: load

 /**
  * {@inheritdoc}
  */
 public function load($module)
 {
     if (isset($module['autoload'])) {
         foreach ($module['autoload'] as $namespace => $path) {
             $this->loader->addPsr4($namespace, $this->resolvePath($module, $path));
         }
     }
     return $module;
 }
开发者ID:LibraryOfLawrence,项目名称:pagekit,代码行数:12,代码来源:AutoLoader.php

示例5: setUp

 protected function setUp()
 {
     $filesystem = new Filesystem();
     $filesystem->remove(__DIR__ . '/Fixtures/tmp');
     $filesystem->mirror(__DIR__ . '/Fixtures/template', __DIR__ . '/Fixtures/tmp');
     $loader = new ClassLoader();
     $loader->addPsr4('Fixtures\\Maba\\Bundle\\', __DIR__ . '/Fixtures/tmp/src');
     $loader->addPsr4('Fixtures\\Maba\\', __DIR__ . '/Fixtures/tmp/app');
     $loader->register(true);
     static::bootKernel();
 }
开发者ID:mariusbalcytis,项目名称:webpack-migration-bundle,代码行数:11,代码来源:FunctionalTest.php

示例6: load

 /**
  * Load bundle
  *
  * @param BundleInterface $bundle
  *
  * @throws MissingBundleException
  */
 public static function load(BundleInterface $bundle)
 {
     if (is_dir($bundle->getPath())) {
         self::$bundlesLoaded[$bundle->getName()] = ['namespace' => $bundle->getNamespace(), 'path' => $bundle->getPath()];
         if (!self::$classLoader) {
             self::$classLoader = new ClassLoader();
         }
         self::$classLoader->addPsr4($bundle->getNamespace(), $bundle->getPath());
         self::$classLoader->register();
     } else {
         throw new MissingBundleException(sprintf('Bundle "%s" could not be found.', $bundle->getName()));
     }
 }
开发者ID:radphp,项目名称:core,代码行数:20,代码来源:Bundles.php

示例7: autoloadPlugin

 /**
  * Registers a plugin's PSR-4 path with the class loader.
  * 
  * @param string $filename
  * @param array $info
  */
 private function autoloadPlugin($filename, array $info)
 {
     if (!empty($info['Namespace']) && !empty($info['Autoload'])) {
         $path = WPMU_PLUGIN_DIR . '/' . dirname($filename) . '/' . trim($info['Autoload'], '/\\');
         $this->autoloader->addPsr4($info['Namespace'], array($path));
     }
 }
开发者ID:wells5609,项目名称:wp-app,代码行数:13,代码来源:MustUsePlugins.php

示例8: addPsr4

 public function addPsr4($prefix, $paths, $prepend = false)
 {
     $this->mainLoader->addPsr4($prefix, $paths, $prepend);
     $this->prefixesPsr4 = array_merge($this->prefixesPsr4, $this->mainLoader->getPrefixesPsr4());
     $this->fallbackDirsPsr4 = array_merge($this->fallbackDirsPsr4, $this->mainLoader->getFallbackDirsPsr4());
     return $this;
 }
开发者ID:phpguard,项目名称:phpguard,代码行数:7,代码来源:Locator.php

示例9: registerNamespace

 /**
  * To register a location to find some classes of a namespace.
  * A namespace can has several locations.
  *
  * @api
  *
  * @param string $namespace
  * @param string $path
  *
  * @return LoaderInterface
  */
 public function registerNamespace(string $namespace, string $path) : LoaderInterface
 {
     if ('\\' !== $namespace[\strlen($namespace) - 1]) {
         $namespace = \ltrim($namespace, '\\') . '\\';
     }
     $this->composerInstance->addPsr4($namespace, $path);
     return $this;
 }
开发者ID:unialteri,项目名称:states,代码行数:19,代码来源:LoaderComposer.php

示例10: register

 /**
  * Register's the annotation driver for the passed configuration.
  *
  * @param \AppserverIo\Appserver\Core\Api\Node\AnnotationRegistryNodeInterface $annotationRegistry The configuration node
  *
  * @return void
  */
 public function register(AnnotationRegistryNodeInterface $annotationRegistry)
 {
     // initialize the composer class loader
     $classLoader = new ClassLoader();
     $classLoader->addPsr4($annotationRegistry->getNamespace(), $annotationRegistry->getDirectoriesAsArray());
     // register the class loader to load annotations
     AnnotationRegistry::registerLoader(array($classLoader, 'loadClass'));
 }
开发者ID:appserver-io,项目名称:appserver,代码行数:15,代码来源:Psr4AnnotationRegistry.php

示例11: getLoader

 /**
  * {@inheritDoc}
  */
 public function getLoader()
 {
     $loader = new ClassLoader();
     foreach ($this->information as $prefix => $paths) {
         $loader->addPsr4($prefix, array_map(array($this, 'prependPathWithBaseDir'), (array) $paths));
     }
     return array($loader, 'loadClass');
 }
开发者ID:phpcq,项目名称:autoload-validation,代码行数:11,代码来源:Psr4Validator.php

示例12: __construct

 public function __construct()
 {
     parent::__construct('fancy_research_links');
     $this->directory = WT_MODULES_DIR . $this->getName();
     // register the namespace
     $loader = new ClassLoader();
     $loader->addPsr4('JustCarmen\\WebtreesAddOns\\FancyResearchLinks\\', WT_MODULES_DIR . $this->getName() . '/app');
     $loader->register();
 }
开发者ID:bschwede,项目名称:fancy_research_links,代码行数:9,代码来源:module.php

示例13: testLoadClass

 /**
  * Tests regular PSR-0 and PSR-4 class loading.
  *
  * @dataProvider getLoadClassTests
  *
  * @param string $class            The fully-qualified class name to test, without preceding namespace separator.
  */
 public function testLoadClass($class)
 {
     $loader = new ClassLoader();
     $loader->add('Namespaced\\', __DIR__ . '/Fixtures');
     $loader->add('Pearlike_', __DIR__ . '/Fixtures');
     $loader->addPsr4('ShinyVendor\\ShinyPackage\\', __DIR__ . '/Fixtures');
     $loader->loadClass($class);
     $this->assertTrue(class_exists($class, false), "->loadClass() loads '{$class}'");
 }
开发者ID:Rudloff,项目名称:composer,代码行数:16,代码来源:ClassLoaderTest.php

示例14: registerLoader

 /**
  * Register classloader for extension
  *
  * @return \Composer\Autoload\ClassLoader
  */
 protected function registerLoader()
 {
     $classpath = __DIR__;
     $nsprefix = __NAMESPACE__ . '\\';
     $loader = new ClassLoader();
     $loader->addPsr4($nsprefix, $classpath);
     $loader->register();
     return $loader;
 }
开发者ID:Hoplite-Software,项目名称:observatory,代码行数:14,代码来源:ExtensionHelper.php

示例15: __construct

 /** {@inheritdoc} */
 public function __construct()
 {
     parent::__construct();
     $this->directory = WT_MODULES_DIR . $this->getName();
     // register the namespaces
     $loader = new ClassLoader();
     $loader->addPsr4('JustCarmen\\WebtreesAddOns\\FancyTreeviewPdf\\', $this->directory . '/app');
     $loader->register();
 }
开发者ID:JustCarmen,项目名称:fancy_treeview_pdf,代码行数:10,代码来源:module.php


注:本文中的Composer\Autoload\ClassLoader::addPsr4方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。