define('IS_MAC', $os === 'MAC' ? true : false); } if (!defined('IS_UNIX')) { define('IS_UNIX', $os !== 'MAC' && $os !== 'WIN' ? true : false); } // Import the platform version library if necessary. if (!class_exists('JPlatform')) { require_once JPATH_PLATFORM . '/platform.php'; } // Import the library loader if necessary. if (!class_exists('JLoader')) { require_once JPATH_PLATFORM . '/loader.php'; } class_exists('JLoader') or die; // Setup the autoloaders. JLoader::setup(); /** * Import the base Joomla Platform libraries. */ // Import the factory library. JLoader::import('joomla.factory'); // Import the exception and error handling libraries. JLoader::import('joomla.error.exception'); /* * If the HTTP_HOST environment variable is set we assume a Web request and * thus we import the request library and most likely clean the request input. */ if (isset($_SERVER['HTTP_HOST'])) { JLoader::register('JRequest', JPATH_PLATFORM . '/joomla/environment/request.php'); // If an application flags it doesn't want this, adhere to that. if (!defined('_JREQUEST_NO_CLEAN') && (bool) ini_get('register_globals')) {
/** * Tests the JLoader::setup method. * We test the registration of the PSR-0 loader. * * @return void * * @since 12.3 */ public function testSetupPsr0() { // We unregister all loader functions if registered. $this->unregisterLoaders(); // Setup the loader with $enablePsr = true. JLoader::setup(true, false, false); // Get the autoload functions $loaders = spl_autoload_functions(); $foundLoadPsr0 = false; $foundLoadAlias = false; // We search the list of autoload functions to see if our method is here. foreach ($loaders as $loader) { if (is_array($loader) && $loader[0] === 'JLoader') { if ($loader[1] === 'loadByPsr0') { $foundLoadPsr0 = true; } if ($loader[1] === 'loadByAlias') { $foundLoadAlias = true; } } } // We expect to find it. $this->assertTrue($foundLoadPsr0); // We expect to find it. $this->assertTrue($foundLoadAlias); }
/** * Tests the JLoader::setup method. * * @return void * * @since 11.4 * @covers JLoader::setup */ public function testSetup() { $loaders = spl_autoload_functions(); // We unregister the two loaders in case they are missing foreach ($loaders as $loader) { if ($loader[0] == 'JLoader' && ($loader[1] == 'load' || $loader[1] == '_autoload')) { spl_autoload_unregister($loader); } } // We call the method under test. JLoader::setup(); // We get the list of autoload functions $newLoaders = spl_autoload_functions(); $foundLoad = false; $foundAutoload = false; // We search the list of autoload functions to see if our methods are there. foreach ($newLoaders as $loader) { if ($loader[0] == 'JLoader' && $loader[1] == 'load') { $foundLoad = true; } if ($loader[0] == 'JLoader' && $loader[1] == '_autoload') { $foundAutoload = true; } } $this->assertThat($foundLoad, $this->isTrue()); $this->assertThat($foundAutoload, $this->isTrue()); }
/** * Tests the JLoader::setup method. * We test the registration of the namespace loader with an invalid case strategy. * We expect the lower case namespace loader to be registered by default. * * @return void * * @since 12.3 * @covers JLoader::setup */ public function testSetupNamespacesInvalidCase() { // We unregister all loader functions if registered. $this->unregisterLoaders(); // Setup the loader with and invalid case strategy and enableNamespace = true. JLoader::setup('invalid', true, false, false); // Get the autoload functions $loaders = spl_autoload_functions(); $foundLoadByNamespaceLowerCase = false; $loadByNamespaceNaturalCase = false; $loadByNamespaceMixedCase = false; // We search the list of autoload functions to see if our methods are here. foreach ($loaders as $loader) { if (is_array($loader) && $loader[0] === 'JLoader') { if ($loader[1] === 'loadByNamespaceLowerCase') { $foundLoadByNamespaceLowerCase = true; } if ($loader[1] === 'loadByNamespaceNaturalCase') { $loadByNamespaceNaturalCase = true; } if ($loader[1] === 'loadByNamespaceMixedCase') { $loadByNamespaceMixedCase = true; } } } // We expect to find only the lower case loader registered. $this->assertTrue($foundLoadByNamespaceLowerCase); $this->assertFalse($loadByNamespaceNaturalCase); $this->assertFalse($loadByNamespaceMixedCase); }
public function getDoctrine() { if (!isset($this->entity_manager)) { // unregister JLoader from SPL autoloader foreach (spl_autoload_functions() as $function) { if (is_array($function) && $function[0] === 'JLoader') { spl_autoload_unregister($function); $this->jloader_unreg = true; } } //Set up Doctrine $doctrine_config = Setup::createAnnotationMetadataConfiguration(array($this->path_to_entities), $this->dev_mode, null, $this->doctrine_cache); if ($this->dev_mode) { $doctrine_config->setAutoGenerateProxyClasses(true); } else { $doctrine_config->setAutoGenerateProxyClasses(AbstractProxyFactory::AUTOGENERATE_FILE_NOT_EXISTS); } $doctrine_config->setEntityNamespaces(array($this->entity_namespace)); $doctrine_conn = array('pdo' => $this); $this->entity_manager = EntityManager::create($doctrine_conn, $doctrine_config); //Re-register JLoader into SPL autoloader if required if ($this->jloader_unreg && method_exists('\\JLoader', 'setup')) { \JLoader::setup(); } } return $this->entity_manager; }
* * @pacakge Joomla.Platform.Namespace.Example * * @since 0.1 * * @link http://www.terrachaos.net TerraChaos Development Network * * @copyright Copyright (C) 2011 - 2013 TerraChaosStudios. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE * */ // Bootstrap J! Platform $root = dirname(__FILE__) . '/../../../..'; require_once $root . '/lib/joomla/libraries/import.php'; // Setup autoloader & import core namespaces. \JLoader::setup(\JLoader::NATURAL_CASE, true); \JLoader::registerNamespace('Table', dirname(__FILE__) . '/table'); // Instantiate the main controller. $controller = new \Table\Controller(); if (!defined('JPATH_SITE')) { define('JPATH_SITE', dirname(__FILE__)); } //$controller->run(); class Module { public function __construct() { } public function run() { $controller = new \Table\Controller();