CoreFiles by mySites.guru
SiteRouterAwareTrait.php58 lines, 1,035 bytes, from Joomla_4.2.0-beta2-Beta-Full_Package.zip
Raw History Compare with 4.2.0-beta1
md5
5daf58ed0b35b62ed815bca318f33822
sha1
0c919bd86126e4bd7370c03f284ad4f0150542c7
sha256
1244cc277284b3c1b86e9ced665641b7b84aad46dc62f771b9225375246f901b
<?php
/**
 * Joomla! Content Management System
 *
 * @copyright  (C) 2022 Open Source Matters, Inc. <https://www.joomla.org>
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */

namespace Joomla\CMS\Router;

\defined('_JEXEC') or die;

/**
 * Defines the trait for a Site Router Aware Class.
 *
 * @since  4.2.0
 */
trait SiteRouterAwareTrait
{
	/**
	 * @var    SiteRouter
	 * @since  4.2.0
	 */
	private $router;

	/**
	 * Get the site router.
	 *
	 * @return  SiteRouter
	 *
	 * @since   4.2.0
	 *
	 * @throws  \UnexpectedValueException May be thrown if the router has not been set.
	 */
	public function getSiteRouter(): SiteRouter
	{
		if ($this->router)
		{
			return $this->router;
		}

		throw new \UnexpectedValueException('SiteRouter not set in ' . __CLASS__);
	}

	/**
	 * Set the router to use.
	 *
	 * @param   SiteRouter  $router  The router to use.
	 *
	 * @return  void
	 *
	 * @since   4.2.0
	 */
	public function setSiteRouter(SiteRouter $router): void
	{
		$this->router = $router;
	}
}

The same content is in 5 releases, Joomla 4.2.0-alpha1 to 4.2.0-beta2. See them all, or every version of this file.