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


PHP ClassLoader::loadClass方法代码示例

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


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

示例1: loadClass

 /**
  * Loads the given class or interface.
  *
  * @param   string  $class  The name of the class
  *
  * @return  boolean|null  True if loaded, null otherwise
  *
  * @since   3.4
  */
 public function loadClass($class)
 {
     if ($result = $this->loader->loadClass($class)) {
         JLoader::applyAliasFor($class);
     }
     return $result;
 }
开发者ID:jasonrgd,项目名称:Digital-Publishing-Platform-Joomla,代码行数:16,代码来源:loader.php

示例2: loadClass

 /**
  * @param string $class
  *
  * @return bool
  */
 public function loadClass($class)
 {
     if (strpos(ltrim($class, '\\'), __NAMESPACE__) === 0) {
         return $this->composer->loadClass($class);
     } elseif ($file = $this->composer->findFile($class)) {
         \Composer\Autoload\includeFile('php://filter/read=influence.reader/resource=' . $file);
         return true;
     }
     return false;
 }
开发者ID:komex,项目名称:influence,代码行数:15,代码来源:Influence.php

示例3: testClassExists

 /**
  * Check if a required class exists, and if not, try to load it via composer and recheck.
  * Can not use directly autoloader with class_exists. Sometimes it's behavior is non consistent
  * with spl_autoload_register.
  *
  * @param string $className
  * @return bool
  */
 private function testClassExists($className)
 {
     if (class_exists($className, false)) {
         return true;
     }
     return $this->composerInstance->loadClass($className) && class_exists($className, false);
 }
开发者ID:rakesh-mohanta,项目名称:states,代码行数:15,代码来源:FinderComposer.php

示例4: tryLoadAllClasses

 /**
  * Check that the auto loading information is correct.
  *
  * @return bool
  */
 public function tryLoadAllClasses()
 {
     $result = true;
     // Trick Contao 2.11 into believing it is installed.
     if (!defined('TL_ROOT')) {
         define('TL_ROOT', '/tmp');
     }
     // Try hacking via Contao autoloader.
     spl_autoload_register(function ($class) {
         if (substr($class, 0, 7) !== 'Contao\\') {
             spl_autoload_call('Contao\\' . $class);
             if (class_exists('Contao\\' . $class, false) && !class_exists($class, false)) {
                 class_alias('Contao\\' . $class, $class);
             }
         }
     });
     // Now try to autoload all classes.
     foreach ($this->classMap as $class => $file) {
         if (!$this->isLoaded($class)) {
             try {
                 if (!$this->loader->loadClass($class)) {
                     $this->output->writeln(sprintf('<error>The autoloader could not load %s (should be found from file %s).</error>', $class, $file));
                     $result = false;
                 }
             } catch (\ErrorException $exception) {
                 $this->output->writeln(sprintf('<error>ERROR loading class %s: "%s".</error>', $class, $exception->getMessage()));
                 $result = false;
             }
         }
     }
     return $result;
 }
开发者ID:contao-community-alliance,项目名称:build-system-tool-autoloading-validation,代码行数:37,代码来源:CheckAutoloading.php

示例5: loadClass

 /**
  * Load class with the option to respect case insensitivity
  *
  * @param string $className
  * @return bool|null
  */
 public function loadClass($className)
 {
     $classFound = $this->composerClassLoader->loadClass($className);
     if (!$classFound && !$this->caseSensitiveClassLoading) {
         $classFound = $this->composerClassLoader->loadClass(strtolower($className));
     }
     return $classFound;
 }
开发者ID:graurus,项目名称:testgit_t37,代码行数:14,代码来源:ClassAliasLoader.php

示例6: loadClass

 public function loadClass($class)
 {
     /* @var ClassLoader $loader */
     if ($this->mainLoader->loadClass($class)) {
         return true;
     }
     return false;
 }
开发者ID:phpguard,项目名称:phpguard,代码行数:8,代码来源:Locator.php

示例7: 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

示例8: loadClass

 /**
  * Load class with the option to respect case insensitivity
  *
  * @param string $className
  * @return bool|null
  */
 public function loadClass($className)
 {
     if (!$this->caseSensitiveClassLoading) {
         $lowerCasedClassName = strtolower($className);
         if ($this->composerClassLoader->findFile($lowerCasedClassName)) {
             return $this->composerClassLoader->loadClass($lowerCasedClassName);
         }
     }
     return $this->composerClassLoader->loadClass($className);
 }
开发者ID:khanhdeux,项目名称:typo3test,代码行数:16,代码来源:ClassAliasLoader.php

示例9: loadClass

 /**
  * Loads the given class or interface and invokes static constructor on it
  *
  * @param string $className The name of the class
  * @return bool|null True if loaded, null otherwise
  */
 public function loadClass($className)
 {
     $result = $this->loader->loadClass($className);
     if ($result === true) {
         //class loaded successfully
         $this->callConstruct($className);
         return true;
     }
     return null;
 }
开发者ID:LobbyOS,项目名称:server,代码行数:16,代码来源:Loader.php

示例10: loadFactory

 /**
  * To load the factory of the stated class and check if it's implementing the good interface.
  *
  * @param string $factoryClassName
  *
  * @return bool
  */
 private function loadFactory(string &$factoryClassName) : bool
 {
     if (!isset($this->factoryAvailabilityList[$factoryClassName])) {
         if (true === \class_exists($factoryClassName, false) || true === $this->composerInstance->loadClass($factoryClassName)) {
             $reflectionClassInstance = new \ReflectionClass($factoryClassName);
             $this->factoryAvailabilityList[$factoryClassName] = $reflectionClassInstance->implementsInterface(FactoryInterface::class);
         } else {
             $this->factoryAvailabilityList[$factoryClassName] = false;
         }
     }
     return $this->factoryAvailabilityList[$factoryClassName];
 }
开发者ID:unialteri,项目名称:states,代码行数:19,代码来源:LoaderComposer.php

示例11: 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.
  * @param bool $prependSeparator Whether to call ->loadClass() with a class name with preceding
  *                               namespace separator, as it happens in PHP 5.3.0 - 5.3.2. See https://bugs.php.net/50731
  */
 public function testLoadClass($class, $prependSeparator = FALSE)
 {
     $loader = new ClassLoader();
     $loader->add('Namespaced\\', __DIR__ . '/Fixtures');
     $loader->add('Pearlike_', __DIR__ . '/Fixtures');
     $loader->addPsr4('ShinyVendor\\ShinyPackage\\', __DIR__ . '/Fixtures');
     if ($prependSeparator) {
         $prepend = '\\';
         $message = "->loadClass() loads '{$class}'.";
     } else {
         $prepend = '';
         $message = "->loadClass() loads '\\{$class}', as required in PHP 5.3.0 - 5.3.2.";
     }
     $loader->loadClass($prepend . $class);
     $this->assertTrue(class_exists($class, false), $message);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:25,代码来源:ClassLoaderTest.php

示例12: loadClass

 /**
  * {@inheritdoc}
  * @codeCoverageIgnore
  */
 public function loadClass($className)
 {
     return $this->autoloader->loadClass($className) === true;
 }
开发者ID:IlyaGluschenko,项目名称:test001,代码行数:8,代码来源:ClassLoaderWrapper.php


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