1 <?php
2 /**
3 * @package Joomla.Libraries
4 * @subpackage Class
5 *
6 * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE.txt
8 */
9
10 defined('_JEXEC') or die;
11
12 use Composer\Autoload\ClassLoader;
13
14 /**
15 * Decorate Composer ClassLoader for Joomla!
16 *
17 * For backward compatibility due to class aliasing in the CMS, the loadClass() method was modified to call
18 * the JLoader::applyAliasFor() method.
19 *
20 * @since 3.4
21 */
22 class JClassLoader
23 {
24 /**
25 * The composer class loader
26 *
27 * @var ClassLoader
28 * @since 3.4
29 */
30 private $loader;
31
32 /**
33 * Constructor
34 *
35 * @param ClassLoader $loader Composer autoloader
36 *
37 * @since 3.4
38 */
39 public function __construct(ClassLoader $loader)
40 {
41 $this->loader = $loader;
42 }
43
44 /**
45 * Loads the given class or interface.
46 *
47 * @param string $class The name of the class
48 *
49 * @return boolean|null True if loaded, null otherwise
50 *
51 * @since 3.4
52 */
53 public function loadClass($class)
54 {
55 if ($result = $this->loader->loadClass($class))
56 {
57 JLoader::applyAliasFor($class);
58 }
59
60 return $result;
61 }
62 }
63