CoreFiles by mySites.guru
CacheControllerFactoryAwareTrait.php68 lines, 1,744 bytes, from Joomla_4.3.0-beta1-Beta-Full_Package.zip
Raw History Compare with 4.2.0-beta3
md5
8ec7e314a4c301383a52dd2e888ee033
sha1
9be61176d31d9317b7ca1551a3a20cb9affa7b98
sha256
e0fdf049614f21723f3418785b7561c1175c478c9b986992ab2088173ba74a27
<?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;

use Joomla\CMS\Factory;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
 * 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 94 releases, Joomla 4.3.0-beta1 to 5.2.0-alpha3. See them all, or every version of this file.