- md5
- ca6bff1cec37007bf9631be9f2c67498
- sha1
- f5802751ae56845192bfab3674fab06aea8e2e8f
- sha256
- 7d6f129df91ae8344861b3da056d27e86520bc7922f4c9f238fe62ac4508dfe9
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\CMS\Dispatcher;
defined('_JEXEC') or die;
use Joomla\CMS\Application\CMSApplicationInterface;
use Joomla\CMS\Helper\ModuleHelper;
use Joomla\Input\Input;
use Joomla\Registry\Registry;
/**
* Base class for a Joomla Module Dispatcher.
*
* @since 4.0.0
*/
abstract class AbstractModuleDispatcher extends Dispatcher
{
/**
* The module instance
*
* @var \stdClass
* @since 4.0.0
*/
protected $module;
/**
* Constructor for Dispatcher
*
* @param \stdClass $module The module
* @param CMSApplicationInterface $app The application instance
* @param Input $input The input instance
*
* @since 4.0.0
*/
public function __construct(\stdClass $module, CMSApplicationInterface $app, Input $input)
{
parent::__construct($app, $input);
$this->module = $module;
}
/**
* Runs the dispatcher.
*
* @return void
*
* @since 4.0.0
*/
public function dispatch()
{
$this->loadLanguage();
$displayData = $this->getLayoutData();
// Abort when display data is false
if ($displayData === false)
{
return;
}
// Execute the layout without the module context
$loader = static function (array $displayData)
{
extract($displayData);
require ModuleHelper::getLayoutPath($displayData['module']->module, $displayData['params']->get('layout', 'default'));
};
$loader($displayData);
}
/**
* Returns the layout data. This function can be overridden by subclasses to add more
* attributes for the layout.
*
* If false is returned, then it means that the dispatch process should be aborted.
*
* @return array|false
*
* @since 4.0.0
*/
protected function getLayoutData()
{
return [
'module' => $this->module,
'app' => $this->app,
'input' => $this->input,
'params' => new Registry($this->module->params),
'template' => $this->app->getTemplate()
];
}
/**
* Load the language.
*
* @return void
*
* @since 4.0.0
*/
protected function loadLanguage()
{
$language = $this->app->getLanguage();
$coreLanguageDirectory = JPATH_BASE;
$extensionLanguageDirectory = JPATH_BASE . '/modules/' . $this->module->module;
$langPaths = $language->getPaths();
// Only load the module's language file if it hasn't been already
if (!$langPaths || (!isset($langPaths[$coreLanguageDirectory]) && !isset($langPaths[$extensionLanguageDirectory])))
{
// 1.5 or Core then 1.6 3PD
$language->load($this->module->module, $coreLanguageDirectory, null, false, true) ||
$language->load($this->module->module, $extensionLanguageDirectory, null, false, true);
}
}
}
No other release has this exact content. See every version of this file.