CoreFiles by mySites.guru
CacheControllerFactoryAwareTrait.php68 lines, 1,747 bytes, from Joomla_6.2.0-Stable-Full_Package.zip
Raw History Compare with 6.1.4
md5
3faf8760f5510a30da99f41aae27e0df
sha1
9e90567d64c0314be6f7b6b2241cca1b5cf51338
sha256
9989a2204dbaf474c648cd364b800a05ad12b970224d6f50f133567e46d403cc
<?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 7.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 9 releases, Joomla 6.2.0-alpha1 to 6.2.0. See them all, or every version of this file.