當前位置: 首頁>>代碼示例>>PHP>>正文


PHP JLoader::setup方法代碼示例

本文整理匯總了PHP中JLoader::setup方法的典型用法代碼示例。如果您正苦於以下問題:PHP JLoader::setup方法的具體用法?PHP JLoader::setup怎麽用?PHP JLoader::setup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在JLoader的用法示例。


在下文中一共展示了JLoader::setup方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: define

    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')) {
開發者ID:acculitx,項目名稱:fleetmatrixsite,代碼行數:31,代碼來源:import.php

示例2: testSetupPsr0

 /**
  * 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);
 }
開發者ID:joomla-projects,項目名稱:media-manager-improvement,代碼行數:34,代碼來源:JLoaderTest.php

示例3: testSetup

 /**
  * 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());
 }
開發者ID:rvsjoen,項目名稱:joomla-platform,代碼行數:35,代碼來源:JLoaderTest.php

示例4: testSetupNamespacesInvalidCase

	/**
	 * 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);
	}
開發者ID:realityking,項目名稱:joomla-platform,代碼行數:52,代碼來源:JLoaderTest.php

示例5: getDoctrine

 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;
 }
開發者ID:netshine,項目名稱:scaffold,代碼行數:27,代碼來源:Database.php

示例6: dirname

 * 
 * @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();
開發者ID:Alibek,項目名稱:joomla-platform-namespace-example,代碼行數:31,代碼來源:Module.php


注:本文中的JLoader::setup方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。