Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
4d24d2b
Deprecate getting the router by the app and introduce a service
laoneo Jan 14, 2022
0a16752
also api
laoneo Jan 14, 2022
cfbe216
cs
laoneo Jan 14, 2022
686a060
Update libraries/src/Application/SiteApplication.php
laoneo Jan 15, 2022
f869288
Update libraries/src/Router/Router.php
laoneo Jan 15, 2022
65a5508
Update libraries/src/Service/Provider/Router.php
laoneo Jan 15, 2022
3f07da2
Update components/com_finder/src/View/Search/HtmlView.php
laoneo Jan 15, 2022
57c66aa
Update libraries/src/Application/ConsoleApplication.php
laoneo Jan 15, 2022
f136660
Update libraries/src/Application/CMSApplication.php
laoneo Jan 15, 2022
bcdbd57
Update libraries/src/Application/CMSWebApplicationInterface.php
laoneo Jan 15, 2022
6f1c027
injection
laoneo Jan 15, 2022
c83bff8
comments
laoneo Jan 15, 2022
20f51aa
Update libraries/src/Router/SiteRouterAwareTrait.php
laoneo Jan 16, 2022
f423e36
Update libraries/src/Application/SiteApplication.php
laoneo Jan 16, 2022
ca15b4a
fallback to app router
laoneo Jan 19, 2022
b67cc3f
Merge branch 'j4/router/deprecate-app' of github.com:Digital-Peak/joo…
laoneo Jan 19, 2022
73c336a
Merge remote-tracking branch 'upstream/4.0-dev' into j4/router/deprec…
laoneo Jan 22, 2022
90ecacf
cs
laoneo Jan 22, 2022
141c762
Merge remote-tracking branch 'upstream/4.0-dev' into j4/router/deprec…
laoneo Jan 24, 2022
7e26664
Merge remote-tracking branch 'upstream/4.2-dev' into j4/router/deprec…
laoneo Jan 25, 2022
3897168
revert
laoneo Jan 25, 2022
4cc3a88
revert
laoneo Jan 25, 2022
63797c6
Merge branch '4.2-dev' into j4/router/deprecate-app
laoneo Feb 4, 2022
82d10dd
Merge branch '4.2-dev' into j4/router/deprecate-app
laoneo Feb 9, 2022
169f768
Merge branch '4.2-dev' into j4/router/deprecate-app
laoneo Feb 23, 2022
60bc771
Merge branch '4.2-dev' into j4/router/deprecate-app
laoneo Feb 25, 2022
51cfca4
Merge branch '4.2-dev' into j4/router/deprecate-app
laoneo Mar 7, 2022
7acfdb8
Merge branch '4.2-dev' into j4/router/deprecate-app
laoneo Mar 10, 2022
f6908c0
catch router not found in installation process
laoneo Mar 10, 2022
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
3 changes: 2 additions & 1 deletion components/com_finder/src/View/Search/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Profiler\Profiler;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Router\SiteRouter;
use Joomla\CMS\Uri\Uri;
use Joomla\Component\Finder\Administrator\Indexer\Query;
use Joomla\Component\Finder\Site\Helper\FinderHelper;
Expand Down Expand Up @@ -160,7 +161,7 @@ public function display($tpl = null)
if (strpos($this->query->input, '"'))
{
// Get the application router.
$router = $app->getRouter();
$router = Factory::getContainer()->get(SiteRouter::class);;

// Fix the q variable in the URL.
if ($router->getVar('q') !== $this->query->input)
Expand Down
3 changes: 2 additions & 1 deletion libraries/src/Application/AdministratorApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ protected function doExecute()
*
* @return Router
*
* @since 3.2
* @since 3.2
* @deprecated 5.0 Inject the router or load it from the dependency injection container
*/
public static function getRouter($name = 'administrator', array $options = array())
{
Expand Down
7 changes: 4 additions & 3 deletions libraries/src/Application/ApiApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public function getTemplate($params = false)
*/
protected function route()
{
$router = $this->getApiRouter();
$router = $this->getContainer()->get(ApiRouter::class);

// Trigger the onBeforeApiRoute event.
PluginHelper::importPlugin('webservices');
Expand Down Expand Up @@ -387,11 +387,12 @@ function ($carry, $route) {
*
* @return ApiRouter
*
* @since 4.0.0
* @since 4.0.0
* @deprecated 5.0 Inject the router or load it from the dependency injection container
*/
public function getApiRouter()
{
return $this->getContainer()->get('ApiRouter');
return $this->getContainer()->get(ApiRouter::class);
}

/**
Expand Down
6 changes: 4 additions & 2 deletions libraries/src/Application/CMSApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use Joomla\CMS\Profiler\Profiler;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Router\Router;
use Joomla\CMS\Router\SiteRouter;
use Joomla\CMS\Session\MetadataManager;
use Joomla\CMS\Session\Session;
use Joomla\CMS\Uri\Uri;
Expand Down Expand Up @@ -595,7 +596,8 @@ public function getPathway()
*
* @return Router
*
* @since 3.2
* @since 3.2
* @deprecated 5.0 Inject the router or load it from the dependency injection container
*/
public static function getRouter($name = null, array $options = array())
{
Expand Down Expand Up @@ -1062,7 +1064,7 @@ protected function route()
// Get the full request URI.
$uri = clone Uri::getInstance();

$router = static::getRouter();
$router = $this->getContainer()->get(SiteRouter::class);
$result = $router->parse($uri, true);

$active = $this->getMenu()->getActive();
Expand Down
3 changes: 2 additions & 1 deletion libraries/src/Application/CMSWebApplicationInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public function getMenu($name = null, $options = array());
*
* @return Router
*
* @since 4.0.0
* @since 4.0.0
* @deprecated 5.0 Inject the router or load it from the dependency injection container
*/
public static function getRouter($name = null, array $options = array());

Expand Down
5 changes: 3 additions & 2 deletions libraries/src/Application/ConsoleApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,9 @@ public function setName(string $name): void
*
* @return Router
*
* @since 4.0.6
* @throws \InvalidArgumentException
* @since 4.0.6
* @throws \InvalidArgumentException
* @deprecated 5.0 Inject the router or load it from the dependency injection container
*/
public static function getRouter($name = null, array $options = array())
{
Expand Down
4 changes: 2 additions & 2 deletions libraries/src/Application/SiteApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ public function dispatch($component = null)

// Set up the params
$document = $this->getDocument();
$router = static::getRouter();
$params = $this->getParams();

// Register the document object with Factory
Expand Down Expand Up @@ -378,7 +377,8 @@ public function getPathway($name = 'site', $options = array())
*
* @return \Joomla\CMS\Router\Router
*
* @since 3.2
* @since 3.2
* @deprecated 5.0 Inject the router or load it from the dependency injection container
*/
public static function getRouter($name = 'site', array $options = array())
{
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ protected static function createContainer(): Container
->registerServiceProvider(new \Joomla\CMS\Service\Provider\Session)
->registerServiceProvider(new \Joomla\CMS\Service\Provider\Toolbar)
->registerServiceProvider(new \Joomla\CMS\Service\Provider\WebAssetRegistry)
->registerServiceProvider(new \Joomla\CMS\Service\Provider\ApiRouter)
->registerServiceProvider(new \Joomla\CMS\Service\Provider\Router)
->registerServiceProvider(new \Joomla\CMS\Service\Provider\User);

return $container;
Expand Down
4 changes: 1 addition & 3 deletions libraries/src/Router/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@ public static function link($client, $url, $xhtml = true, $tls = self::TLS_IGNOR
// Get the router instance, only attempt when a client name is given.
if ($client && !isset(self::$_router[$client]))
{
$app = Factory::getApplication();

self::$_router[$client] = $app->getRouter($client);
self::$_router[$client] = Factory::getContainer()->get(ucfirst($client) . 'Router');
}

// Make sure that we have our router
Expand Down
5 changes: 3 additions & 2 deletions libraries/src/Router/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ class Router
*
* @return Router A Router object.
*
* @since 1.5
* @throws \RuntimeException
* @since 1.5
* @throws \RuntimeException
* @deprecated 5.0 Inject the router or load it from the dependency injection container
*/
public static function getInstance($client, $options = array())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
\defined('JPATH_PLATFORM') or die;

use Joomla\CMS\Application\ApiApplication;
use Joomla\CMS\Application\SiteApplication;
use Joomla\CMS\Router\AdministratorRouter;
use Joomla\CMS\Router\ApiRouter;
use Joomla\CMS\Router\SiteRouter;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;

Expand All @@ -19,7 +23,7 @@
*
* @since 4.0.0
*/
class ApiRouter implements ServiceProviderInterface
class Router implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
Expand All @@ -32,12 +36,32 @@ class ApiRouter implements ServiceProviderInterface
*/
public function register(Container $container)
{
$container->alias('ApiRouter', 'Joomla\CMS\Router\ApiRouter')
$container->alias('SiteRouter', SiteRouter::class)
->share(
'Joomla\CMS\Router\ApiRouter',
SiteRouter::class,
function (Container $container)
{
return new \Joomla\CMS\Router\ApiRouter($container->get(ApiApplication::class));
return new SiteRouter($container->get(SiteApplication::class));
},
true
);

$container->alias('AdministratorRouter', AdministratorRouter::class)
->share(
AdministratorRouter::class,
function (Container $container)
{
return new AdministratorRouter();
},
true
);

$container->alias('ApiRouter', ApiRouter::class)
->share(
ApiRouter::class,
function (Container $container)
{
return new ApiRouter($container->get(ApiApplication::class));
},
true
);
Expand Down
2 changes: 1 addition & 1 deletion plugins/system/cache/cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ protected function isExcluded()
$exclusions = explode("\n", $exclusions);

// Gets internal URI.
$internal_uri = '/index.php?' . Uri::getInstance()->buildQuery($this->app->getRouter()->getVars());
$internal_uri = '/index.php?' . Uri::getInstance()->buildQuery(Factory::getContainer()->get(SiteRouter::class)->getVars());

// Loop through each pattern.
if ($exclusions)
Expand Down
3 changes: 2 additions & 1 deletion plugins/system/languagefilter/languagefilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Router\Router;
use Joomla\CMS\Router\SiteRouter;
use Joomla\CMS\Uri\Uri;
use Joomla\Component\Menus\Administrator\Helper\MenusHelper;
use Joomla\Registry\Registry;
Expand Down Expand Up @@ -764,7 +765,7 @@ public function onAfterDispatch()
$remove_default_prefix = $this->params->get('remove_default_prefix', 0);
$server = Uri::getInstance()->toString(array('scheme', 'host', 'port'));
$is_home = false;
$currentInternalUrl = 'index.php?' . http_build_query($this->app->getRouter()->getVars());
$currentInternalUrl = 'index.php?' . http_build_query(Factory::getContainer()->get(SiteRouter::class)->getVars());

if ($active)
{
Expand Down