/** * Method to setup the autoloaders for the Joomla Platform. * Since the SPL autoloaders are called in a queue we will add our explicit * class-registration based loader first, then fall back on the autoloader based on conventions. * This will allow people to register a class in a specific location and override platform libraries * as was previously possible. * * @param integer $caseStrategy An option to define the class finding strategy for the namespace loader * depending on the namespace and class path case. * The possible values are : * JLoader::LOWER_CASE : The namespace can be either lower case or camel case and the path lower case. * JLoader::NATURAL_CASE : The namespace case matches the path case. * JLoader::MIXED_CASE : It regroups option 1 and option 2. * @param boolean $enableNamespaces True to enable PHP namespace based class autoloading. * @param boolean $enablePrefixes True to enable prefix based class loading (needed to auto load the Joomla core). * @param boolean $enableClasses True to enable class map based class loading (needed to auto load the Joomla core). * * @return void * * @since 12.3 */ public static function setup($caseStrategy = self::LOWER_CASE, $enableNamespaces = true, $enablePrefixes = true, $enableClasses = true, $enableCompatLayer = true) { if ($enableCompatLayer) { self::$nsMap = (include JPATH_PLATFORM . '/compat/NamespaceMap.php'); spl_autoload_register(array(__CLASS__, 'compatLayer')); } spl_autoload_register(array(__CLASS__, 'loadByPsr0')); self::registerNamespace('Joomla', JPATH_PLATFORM); if ($enableClasses) { // Register the class map based autoloader. spl_autoload_register(array(__CLASS__, 'load')); } if ($enablePrefixes) { // Register the prefix autoloader. spl_autoload_register(array(__CLASS__, '_autoload')); } if ($enableNamespaces) { switch ($caseStrategy) { // Register the natural case namespace loader. case self::NATURAL_CASE: spl_autoload_register(array(__CLASS__, 'loadByNamespaceNaturalCase')); break; // Register the mixed case namespace loader. // Register the mixed case namespace loader. case self::MIXED_CASE: spl_autoload_register(array(__CLASS__, 'loadByNamespaceMixedCase')); break; // Default to the lower case namespace loader. // Default to the lower case namespace loader. case self::LOWER_CASE: default: spl_autoload_register(array(__CLASS__, 'loadByNamespaceLowerCase')); break; } } }