Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
1cd29cb
Add getLanguage function to interface
laoneo Jun 29, 2017
5d373d3
Deprecate getInstance function
laoneo Jun 29, 2017
4ace48b
Factory returns global application object
laoneo Jun 29, 2017
59dc9a5
Load the application trough the container
laoneo Jun 29, 2017
aa44db1
SiteRouter should load the app trough the container
laoneo Jun 29, 2017
7f03466
Load the database when required and not on construct
laoneo Jun 29, 2017
2603238
Get the container from the global application
laoneo Jun 29, 2017
b375ef2
Remove container code from the Factory
laoneo Jun 29, 2017
96c5cda
Change the getContainer from app
laoneo Jun 29, 2017
ce300b4
Change cli files
laoneo Jun 29, 2017
12b512a
Merge remote-tracking branch 'remotes/upstream/4.0-dev' into j4/remov…
laoneo Jun 29, 2017
fdd213a
fixing tests
laoneo Jun 29, 2017
6ef3e50
Stabilizing core
laoneo Jun 29, 2017
6708c8f
cs
laoneo Jun 29, 2017
2c04433
cleanup tests
laoneo Jun 30, 2017
2031eb6
cleanup tests
laoneo Jun 30, 2017
abaa348
harmonize front controller
laoneo Jun 30, 2017
d241488
simplify tests
laoneo Jun 30, 2017
fbefa18
mock the container
laoneo Jun 30, 2017
22e21ea
needs a CMS app
laoneo Jun 30, 2017
e5f6af5
getApplication has no arguments anymore
laoneo Jun 30, 2017
f5d11a3
cs
laoneo Jun 30, 2017
56c9270
better doc
laoneo Jun 30, 2017
4bdd7c5
deprecate the genInstance function on the applications
laoneo Jun 30, 2017
c4dfbf1
deprecated
laoneo Jun 30, 2017
7a5b8cb
Change to interface return type
laoneo Jun 30, 2017
99685e2
support alias in container for apps
laoneo Jun 30, 2017
4cbffc3
Should always be available
laoneo Jun 30, 2017
88bb57f
save and restore factory state in tests
laoneo Jun 30, 2017
001a1f6
fix tests
laoneo Jun 30, 2017
77ed3e6
remove not needed alias
laoneo Jun 30, 2017
0f6cb85
Remove the installer session service provider as it works with the de…
laoneo Jun 30, 2017
1911667
Merge remote-tracking branch 'remotes/upstream/4.0-dev' into j4/sync-…
laoneo Aug 17, 2017
bd4ca0a
Restore the Factory::getContainer function and deprecate it
laoneo Aug 17, 2017
f7c01b3
Revert tests
laoneo Aug 17, 2017
f15ffe8
Improve deprecated messages
laoneo Aug 17, 2017
f9afe1c
Set the global container in the factory in the front controller
laoneo Aug 17, 2017
af85a80
Merge remote-tracking branch 'remotes/upstream/4.0-dev' into j4/sync-…
laoneo Aug 18, 2017
2ea8166
Merge remote-tracking branch 'origin/j4/sync-app-setup' into j4/sync-…
laoneo Aug 18, 2017
aadb604
Revert test
laoneo Aug 18, 2017
5677848
Merge remote-tracking branch 'remotes/upstream/4.0-dev' into j4/sync-…
laoneo Aug 22, 2017
743fd56
Merge remote-tracking branch 'remotes/upstream/4.0-dev' into j4/sync-…
laoneo Aug 23, 2017
42d4279
Merge branch '4.0-dev' into j4/sync-app-setup
laoneo Feb 2, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions administrator/includes/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,17 @@

require_once JPATH_BASE . '/includes/framework.php';

/** @var \Joomla\DI\Container $container */
$container = require JPATH_LIBRARIES . '/container.php';

// Set the container as global one
\Joomla\CMS\Factory::$container = $container;

// Set profiler start time and memory usage and mark afterLoad in the profiler.
JDEBUG ? JProfiler::getInstance('Application')->setStart($startTime, $startMem)->mark('afterLoad') : null;

// Instantiate the application.
$app = JFactory::getApplication('administrator');
// Get the application from the container
$app = $container->get(\Joomla\CMS\Application\AdministratorApplication::class);

// Execute the application.
$app->execute();
21 changes: 17 additions & 4 deletions build/helpTOC.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,22 +215,35 @@ public function doExecute()
}
}

/** @var \Joomla\DI\Container $container */
$container = require JPATH_LIBRARIES . '/container.php';

// Set the container as global one
\Joomla\CMS\Factory::$container = $container;

// Set up the container
JFactory::getContainer()->share(
$container->share(
'MediawikiCli',
function (\Joomla\DI\Container $container)
{
return new MediawikiCli(
$app = new MediawikiCli(
null,
null,
null,
null,
$container->get(\Joomla\Event\DispatcherInterface::class),
$container
);

JFactory::$application = $app;

return $app;
},
true
);
$app = JFactory::getContainer()->get('MediawikiCli');
JFactory::$application = $app;

// Get the application from the container
$app = $container->get('MediawikiCli');

// Execute the application.
$app->execute();
21 changes: 17 additions & 4 deletions cli/finder_indexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,22 +360,35 @@ private function getFilters()
}
}

/** @var \Joomla\DI\Container $container */
$container = require JPATH_LIBRARIES . '/container.php';

// Set the container as global one
\Joomla\CMS\Factory::$container = $container;

// Set up the container
JFactory::getContainer()->share(
$container->share(
'FinderCli',
function (\Joomla\DI\Container $container)
{
return new FinderCli(
$app = new FinderCli(
null,
null,
null,
null,
$container->get(\Joomla\Event\DispatcherInterface::class),
$container
);

\Joomla\CMS\Factory::$application = $app;

return $app;
},
true
);
$app = JFactory::getContainer()->get('FinderCli');
JFactory::$application = $app;

// Get the application from the container
$app = $container->get('FinderCli');

// Execute the application.
$app->execute();
10 changes: 8 additions & 2 deletions includes/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,17 @@

require_once JPATH_BASE . '/includes/framework.php';

/** @var \Joomla\DI\Container $container */
$container = require JPATH_LIBRARIES . '/container.php';

// Set the container as global one
\Joomla\CMS\Factory::$container = $container;

// Set profiler start time and memory usage and mark afterLoad in the profiler.
JDEBUG ? JProfiler::getInstance('Application')->setStart($startTime, $startMem)->mark('afterLoad') : null;

// Instantiate the application.
$app = JFactory::getApplication('site');
// Get the application from the container
$app = $container->get(\Joomla\CMS\Application\SiteApplication::class);

// Execute the application.
$app->execute();
22 changes: 22 additions & 0 deletions libraries/container.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* @package Joomla.Libraries
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

// No direct access.
defined('_JEXEC') or die;

$container = (new \Joomla\DI\Container)
->registerServiceProvider(new \Joomla\CMS\Service\Provider\Application)
->registerServiceProvider(new \Joomla\CMS\Service\Provider\Database)
->registerServiceProvider(new \Joomla\CMS\Service\Provider\Dispatcher)
->registerServiceProvider(new \Joomla\CMS\Service\Provider\Form)
->registerServiceProvider(new \Joomla\CMS\Service\Provider\Document)
->registerServiceProvider(new \Joomla\CMS\Service\Provider\Menu)
->registerServiceProvider(new \Joomla\CMS\Service\Provider\Session)
->registerServiceProvider(new \Joomla\CMS\Service\Provider\Toolbar);

return $container;
10 changes: 10 additions & 0 deletions libraries/src/Application/CMSApplicationInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace Joomla\CMS\Application;

use Joomla\CMS\Language\Language;
use Joomla\CMS\User\User;
use Joomla\Session\SessionInterface;

Expand Down Expand Up @@ -132,6 +133,15 @@ public function isClient($identifier);
*/
public function getSession();

/**
* Method to get the application language object.
*
* @return Language The language object
*
* @since __DEPLOY_VERSION__
*/
public function getLanguage();

/**
* Flag if the application instance is a CLI or web based application.
*
Expand Down
3 changes: 2 additions & 1 deletion libraries/src/Document/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,8 @@ public function __construct($options = array())
*
* @return static The document object.
*
* @since 11.1
* @since 11.1
* @deprecated 5.0 Use the document factory
*/
public static function getInstance($type = 'html', $attributes = array())
{
Expand Down
31 changes: 15 additions & 16 deletions libraries/src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

defined('JPATH_PLATFORM') or die;

use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Application\CMSApplicationInterface;
use Joomla\CMS\Cache\Cache;
use Joomla\CMS\Date\Date;
use Joomla\CMS\Document\Document;
Expand Down Expand Up @@ -38,7 +38,7 @@ abstract class Factory
/**
* Global application object
*
* @var CMSApplication
* @var CMSApplicationInterface
* @since 11.1
*/
public static $application = null;
Expand All @@ -63,8 +63,9 @@ abstract class Factory
/**
* Global container object
*
* @var Container
* @since 4.0
* @var Container
* @since 4.0
* @deprecated 5.0 Don't us it, it is needed for the transition period
*/
public static $container = null;

Expand Down Expand Up @@ -118,18 +119,10 @@ abstract class Factory
public static $mailer = null;

/**
* Get an application object.
* Get the global application object.
*
* Returns the global {@link CMSApplication} object, only creating it if it doesn't already exist.
* @return CMSApplicationInterface object
*
* @param mixed $id A client identifier or name.
* @param array $config An optional associative array of configuration settings.
* @param string $prefix Application prefix
* @param Container $container An optional dependency injection container to inject into the application.
*
* @return CMSApplication object
*
* @see JApplication
* @since 11.1
* @throws \Exception
*/
Expand Down Expand Up @@ -202,9 +195,14 @@ public static function getConfig($file = null, $type = 'PHP', $namespace = '')
*
* Returns the global service container object, only creating it if it doesn't already exist.
*
* This method exists to bridge the CMS architecture to a service injection based structure.
* Use of this method outside of service factory methods (i.e. a static getInstance() method
* or a method which builds class services) is highly discouraged.
*
* @return Container
*
* @since 4.0
* @since 4.0
* @deprecated 5.0 For the current state it is not known when this function will be removed
*/
public static function getContainer(): Container
{
Expand Down Expand Up @@ -511,7 +509,8 @@ protected static function createConfig($file, $type = 'PHP', $namespace = '')
*
* @return Container
*
* @since 4.0
* @since 4.0
* @deprecated See Factory::getContainer()
*/
protected static function createContainer(): Container
{
Expand Down
81 changes: 48 additions & 33 deletions libraries/src/Filter/InputFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class InputFilter extends BaseInputFilter
* @var integer
* @since 3.5
*/
public $stripUSC = 0;
private $stripUSC = 0;

/**
* Constructor for inputFilter class. Only first parameter is required.
Expand All @@ -49,37 +49,6 @@ public function __construct($tagsArray = array(), $attrArray = array(), $tagsMet

// Assign member variables
$this->stripUSC = $stripUSC;

/**
* If Unicode Supplementary Characters stripping is not set we have to check with the database driver. If the
* driver does not support USCs (i.e. there is no utf8mb4 support) we will enable USC stripping.
*/
if ($this->stripUSC === -1)
{
try
{
// Get the database driver
$db = \JFactory::getDbo();

if ($db instanceof UTF8MB4SupportInterface)
{
// This trick is required to let the driver determine the utf-8 multibyte support
$db->connect();

// And now we can decide if we should strip USCs
$this->stripUSC = $db->hasUTF8mb4Support() ? 0 : 1;
}
else
{
$this->stripUSC = 1;
}
}
catch (\RuntimeException $e)
{
// Could not connect to the database. Strip USC to be on the safe side.
$this->stripUSC = 1;
}
}
}

/**
Expand Down Expand Up @@ -139,7 +108,7 @@ public static function &getInstance($tagsArray = array(), $attrArray = array(),
public function clean($source, $type = 'string')
{
// Strip Unicode Supplementary Characters when requested to do so
if ($this->stripUSC)
if ($this->isStripUSC())
{
// Alternatively: preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xE2\xAF\x91", $source) but it'd be slower.
$source = $this->stripUSC($source);
Expand Down Expand Up @@ -528,4 +497,50 @@ protected function stripUSC($source)

return preg_replace('/[\xF0-\xF7].../s', "\xE2\xAF\x91", $source);
}

/**
* Returns if USC should be stripped.
*
* @return boolean If USC should be stripped
*
* @since __DEPLOY_VERSION__
*/
private function isStripUSC()
{
// Flag is set
if ($this->stripUSC != -1)
{
return $this->stripUSC;
}

/**
* If Unicode Supplementary Characters stripping is not set we have to check with the database driver. If the
* driver does not support USCs (i.e. there is no utf8mb4 support) we will enable USC stripping.
*/
try
{
// Get the database driver
$db = \JFactory::getDbo();

if ($db instanceof UTF8MB4SupportInterface)
{
// This trick is required to let the driver determine the utf-8 multibyte support
$db->connect();

// And now we can decide if we should strip USCs
$this->stripUSC = $db->hasUTF8mb4Support() ? 0 : 1;
}
else
{
$this->stripUSC = 1;
}
}
catch (\RuntimeException $e)
{
// Could not connect to the database. Strip USC to be on the safe side.
$this->stripUSC = 1;
}

return $this->stripUSC === 1;
}
}
1 change: 1 addition & 0 deletions libraries/src/Menu/AbstractMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public function __construct($options = array())
*
* @since 1.5
* @throws \Exception
* @deprecated 5.0 Use the menu factory instead
*/
public static function getInstance($client, $options = array())
{
Expand Down
5 changes: 3 additions & 2 deletions libraries/src/Pathway/Pathway.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ class Pathway
*
* @return Pathway A Pathway object.
*
* @since 1.5
* @throws \RuntimeException
* @since 1.5
* @throws \RuntimeException
* @deprecated 5.0 Instantiate the object directly
*/
public static function getInstance($client, $options = array())
{
Expand Down
Loading