Skip to content

Commit

Permalink
Change default behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
laoneo committed Dec 30, 2021
1 parent ef15ffe commit 3e8f2d1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions libraries/src/Application/ConsoleApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

\defined('JPATH_PLATFORM') or die;

use InvalidArgumentException;
use Joomla\CMS\Console;
use Joomla\CMS\Extension\ExtensionManagerTrait;
use Joomla\CMS\Factory;
Expand Down Expand Up @@ -449,12 +450,18 @@ public function setName(string $name): void
* @return Router
*
* @since __DEPLOY_VERSION__
* @throws \InvalidArgumentException
*/
public static function getRouter($name = null, array $options = array())
{
if (!isset($name) || Factory::getApplication()->getName() === $name)
if (!isset($name))
{
throw new InvalidArgumentException('A router name must be set in console application.');
}

// Fallback to site router when console router is fetched
if (Factory::getApplication()->getName() === $name)
{
// Use site as default as there is no console router
$name = 'site';
}

Expand Down

0 comments on commit 3e8f2d1

Please sign in to comment.