/**
  * 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;
 }
Esempio n. 2
0
 /**
  * @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;
 }
Esempio n. 3
0
 /**
  * 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);
 }
 /**
  * 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;
 }
Esempio n. 5
0
 /**
  * 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;
 }
Esempio n. 6
0
 public function loadClass($class)
 {
     /* @var ClassLoader $loader */
     if ($this->mainLoader->loadClass($class)) {
         return true;
     }
     return false;
 }
Esempio n. 7
0
 /**
  * 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}'");
 }
Esempio n. 8
0
 /**
  * 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);
 }
Esempio n. 9
0
 /**
  * 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;
 }
Esempio n. 10
0
 /**
  * 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];
 }
Esempio n. 11
0
 /**
  * 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);
 }
 /**
  * {@inheritdoc}
  * @codeCoverageIgnore
  */
 public function loadClass($className)
 {
     return $this->autoloader->loadClass($className) === true;
 }