當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。