CoreFiles by mySites.guru
LegacyComponentDispatcher.php73 lines, 1,555 bytes, from Joomla_4.0.0-beta2-Beta-Full_Package.zip
Raw History Compare with 4.0.0-beta
md5
3762f3f266f9a842342398d5f030df01
sha1
b3aa3977dc0e5309c2e6b5164ff6ee13fca60abe
sha256
014254291f960b6b5046c56d01f686be7c29acab8b220d1c1d1247c1e5a58c47
<?php
/**
 * Joomla! Content Management System
 *
 * @copyright  Copyright (C) 2005 - 2020 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\CMSApplication;
use Joomla\CMS\Language\Text;

/**
 * Base class for a legacy Joomla Dispatcher
 *
 * Executes the single entry file of a legacy component.
 *
 * @since  4.0.0
 */
class LegacyComponentDispatcher implements DispatcherInterface
{
	/**
	 * The application instance
	 *
	 * @var    CMSApplication
	 * @since  4.0.0
	 */
	private $app;

	/**
	 * Constructor for Dispatcher
	 *
	 * @param   CMSApplication  $app  The application instance
	 *
	 * @since   4.0.0
	 */
	public function __construct(CMSApplication $app)
	{
		$this->app = $app;
	}

	/**
	 * Dispatch a controller task. Redirecting the user if appropriate.
	 *
	 * @return  void
	 *
	 * @since   4.0.0
	 */
	public function dispatch()
	{
		$path = JPATH_COMPONENT . '/' . substr($this->app->scope, 4) . '.php';

		// If component file doesn't exist throw error
		if (!file_exists($path))
		{
			throw new \Exception(Text::_('JLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND'), 404);
		}

		$lang = $this->app->getLanguage();

		// Load common and local language files.
		$lang->load($this->app->scope, JPATH_BASE) || $lang->load($this->app->scope, JPATH_COMPONENT);

		// Execute the component
		$loader = static function ($path) {
			require_once $path;
		};
		$loader($path);
	}
}

The same content is in 4 releases, Joomla 4.0.0-beta to 4.0.0-beta4. See them all, or every version of this file.