CoreFiles by mySites.guru
CacheControllerFactoryAwareTrait.php66 lines, 1,672 bytes, from Joomla_4.2.5-Stable-Full_Package.zip
Raw History Compare with 4.2.4
md5
ff4f49b4a316d812f8935b1fc45b07d2
sha1
b5a7c40909d59d715233accaf0531aca5b6625d6
sha256
53903360fc8602341b322cfde605dc43714d1c9ebac5e6a72e3cf9475b5369f3
<?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 11 releases, Joomla 4.2.5 to 4.3.0-alpha3. See them all, or every version of this file.