CoreFiles by mySites.guru
CacheControllerFactoryAwareTrait.php66 lines, 1,513 bytes, from Joomla_4.2.0-beta2-Beta-Full_Package.zip
Raw History Compare with 4.2.0-beta1
md5
80a50d8b8d7ccf2a2d0b6b1eb57fac47
sha1
ae18d9daab1028c219c7a5e87bb58fd3dd0d79b5
sha256
78d345c0e57e7e6f81a903453d9542cc0fd52c09950d9bf580736a318942d4cb
<?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\Cache;

\defined('_JEXEC') or die;

use Joomla\CMS\Factory;

/**
 * Defines the trait for a CacheControllerFactoryInterface Aware Class.
 *
 * @since  4.2.0
 */
trait CacheControllerFactoryAwareTrait
{
	/**
	 * CacheControllerFactoryInterface
	 *
	 * @var    CacheControllerFactoryInterface
	 *
	 * @since  4.2.0
	 */
	private $cacheControllerFactory;

	/**
	 * Get the CacheControllerFactoryInterface.
	 *
	 * @return  CacheControllerFactoryInterface
	 *
	 * @since   4.2.0
	 */
	protected function getCacheControllerFactory(): CacheControllerFactoryInterface
	{
		if ($this->cacheControllerFactory)
		{
			return $this->cacheControllerFactory;
		}

		@trigger_error(
			sprintf('A cache controller is needed in %s. An UnexpectedValueException will be thrown in 5.0.', __CLASS__),
			E_USER_DEPRECATED
		);

		return Factory::getContainer()->get(CacheControllerFactoryInterface::class);
	}

	/**
	 * Set the cache controller factory to use.
	 *
	 * @param   CacheControllerFactoryInterface  $cacheControllerFactory  The cache controller factory to use.
	 *
	 * @return  void
	 *
	 * @since   4.2.0
	 */
	public function setCacheControllerFactory(CacheControllerFactoryInterface $cacheControllerFactory = null): void
	{
		$this->cacheControllerFactory = $cacheControllerFactory;
	}
}

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