CoreFiles by mySites.guru
LegacyComponentDispatcher.php73 lines, 1,590 bytes, from Joomla_4.0.0-alpha5-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha3
md5
b2339b50365588f40cafcbb572a16a39
sha1
cbdc4d7b0d8c0424376047f3a41a1bae76b27541
sha256
def616437586128acf179df5c369e79a687470c8c7a1635fca46ecae77563b85
<?php
/**
 * Joomla! Content Management System
 *
 * @copyright  Copyright (C) 2005 - 2018 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, null, false, true) || $lang->load($this->app->scope, JPATH_COMPONENT, null, false, true);

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

The same content is in 2 releases, Joomla 4.0.0-alpha5 to 4.0.0-alpha6. See them all, or every version of this file.