Skip to content

Commit

Permalink
Move creator file to a trait in the application
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonge committed Jun 3, 2017
1 parent bfa7672 commit 5f1695c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 5 deletions.
4 changes: 0 additions & 4 deletions libraries/bootstrap.php
Expand Up @@ -95,10 +95,6 @@
JLoader::registerAlias('JAdministrator', 'JApplicationAdministrator');
JLoader::registerAlias('JSite', 'JApplicationSite');

//JLoader::register('JNamespacePsr4Map', JPATH_LIBRARIES . '/namespacemap.php');
//$extensionPsr4Loader = new JNamespacePsr4Map;
//$extensionPsr4Loader->ensureMapFileExists();

// Can be removed when the move of all core fields to namespace is finished
\Joomla\CMS\Form\FormHelper::addFieldPath(JPATH_LIBRARIES . '/joomla/form/fields');
\Joomla\CMS\Form\FormHelper::addRulePath(JPATH_LIBRARIES . '/joomla/form/rule');
Expand Down
4 changes: 3 additions & 1 deletion libraries/src/CMS/Application/CMSApplication.php
Expand Up @@ -31,7 +31,7 @@
*/
abstract class CMSApplication extends WebApplication implements ContainerAwareInterface
{
use ContainerAwareTrait;
use ContainerAwareTrait, ExtensionNamespaceMapper;

/**
* Constant defining an enqueued emergency message
Expand Down Expand Up @@ -201,6 +201,8 @@ public function __construct(\JInput $input = null, Registry $config = null, WebC
{
$this->config->set('session_name', $this->getName());
}

$this->createExtensionNamespaceMap();
}

/**
Expand Down
35 changes: 35 additions & 0 deletions libraries/src/CMS/Application/ExtensionNamespaceMapper.php
@@ -0,0 +1,35 @@
<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/

namespace Joomla\CMS\Application;

defined('JPATH_PLATFORM') or die;

use JLoader;

/**
* Trait for application classes which ensures the namespace mapper exists and includes it.
*
* @since 4.0
*/
trait ExtensionNamespaceMapper
{
/**
* Allows the application to load a custom or default identity.
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function createExtensionNamespaceMap()
{
JLoader::register('JNamespacePsr4Map', JPATH_LIBRARIES . '/namespacemap.php');
$extensionPsr4Loader = new \JNamespacePsr4Map;
$extensionPsr4Loader->ensureMapFileExists();
}
}

0 comments on commit 5f1695c

Please sign in to comment.