Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 12 additions & 5 deletions libraries/src/Application/CMSApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ abstract class CMSApplication extends WebApplication implements ContainerAwareIn
/**
* The pathway object
*
* @var Pathway
* @var Pathway[]
* @since __DEPLOY_VERSION__
*/
protected $pathway = null;
protected $pathway = [];

/**
* Class constructor.
Expand Down Expand Up @@ -603,12 +603,19 @@ public function getPathway($name = null)
$name = $this->getName();
}

if (!$this->pathway)
$name = strtolower($name);

if (!array_key_exists($name . 'pathway', $this->pathway))
{
$this->pathway = $this->getContainer()->get(ucfirst($name) . 'Pathway');
if (!$this->getContainer()->has(ucfirst($name) . 'Pathway'))
{
throw new \RuntimeException(\JText::sprintf('JLIB_APPLICATION_ERROR_PATHWAY_LOAD', $name), 500);
}

$this->pathway[$name . 'pathway'] = $this->getContainer()->get(ucfirst($name) . 'Pathway');
}

return $this->pathway;
return $this->pathway[$name . 'pathway'];
}

/**
Expand Down
13 changes: 13 additions & 0 deletions libraries/src/Service/Provider/Pathway.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
defined('JPATH_PLATFORM') or die;

use Joomla\CMS\Application\SiteApplication;
use Joomla\CMS\Pathway\Pathway as GlobalPathway;
use Joomla\CMS\Pathway\SitePathway;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
Expand Down Expand Up @@ -44,5 +45,17 @@ function (Container $container)
},
true
);

$container->alias('Pathway', GlobalPathway::class)
->alias('JPathway', GlobalPathway::class)
->alias('pathway', GlobalPathway::class)
->share(
GlobalPathway::class,
function (Container $container)
{
return new GlobalPathway;
},
true
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,12 @@ public function setUp()
$config = new Registry;
$config->set('session', false);

$container = new \Joomla\DI\Container;
$pathwayProvider = new \Joomla\CMS\Service\Provider\Pathway;
$pathwayProvider->register($container);

// Get a new JApplicationCmsInspector instance.
$this->class = new JApplicationCmsInspector($this->getMockInput(), $config);
$this->class = new JApplicationCmsInspector($this->getMockInput(), $config, null, $container);
$this->class->setSession(JFactory::$session);
$this->class->setDispatcher($this->getMockDispatcher());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,16 @@ public function setUp()
$config = new Registry;
$config->set('session', false);

$container = new \Joomla\DI\Container;
$pathwayProvider = new \Joomla\CMS\Service\Provider\Pathway;
$pathwayProvider->register($container);

// Get a new JApplicationSite instance.
$this->class = new JApplicationSite($this->getMockInput(), $config);
$this->class->setSession(JFactory::$session);
$this->class->setDispatcher($this->getMockDispatcher());
$container->set('Joomla\CMS\Application\SiteApplication', $this->class);
$this->class->setContainer($container);
TestReflection::setValue('JApplicationCms', 'instances', array('site' => $this->class));

JFactory::$application = $this->class;
Expand Down