[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/Cache/ -> CacheControllerFactoryAwareTrait.php (source)

   1  <?php
   2  /**
   3   * Joomla! Content Management System
   4   *
   5   * @copyright  (C) 2022 Open Source Matters, Inc. <https://www.joomla.org>
   6   * @license    GNU General Public License version 2 or later; see LICENSE.txt
   7   */
   8  
   9  namespace Joomla\CMS\Cache;
  10  
  11  \defined('_JEXEC') or die;
  12  
  13  use Joomla\CMS\Factory;
  14  
  15  /**
  16   * Defines the trait for a CacheControllerFactoryInterface Aware Class.
  17   *
  18   * @since  4.2.0
  19   */
  20  trait CacheControllerFactoryAwareTrait
  21  {
  22      /**
  23       * CacheControllerFactoryInterface
  24       *
  25       * @var    CacheControllerFactoryInterface
  26       *
  27       * @since  4.2.0
  28       */
  29      private $cacheControllerFactory;
  30  
  31      /**
  32       * Get the CacheControllerFactoryInterface.
  33       *
  34       * @return  CacheControllerFactoryInterface
  35       *
  36       * @since   4.2.0
  37       */
  38  	protected function getCacheControllerFactory(): CacheControllerFactoryInterface
  39      {
  40          if ($this->cacheControllerFactory)
  41          {
  42              return $this->cacheControllerFactory;
  43          }
  44  
  45          @trigger_error(
  46              sprintf('A cache controller is needed in %s. An UnexpectedValueException will be thrown in 5.0.', __CLASS__),
  47              E_USER_DEPRECATED
  48          );
  49  
  50          return Factory::getContainer()->get(CacheControllerFactoryInterface::class);
  51      }
  52  
  53      /**
  54       * Set the cache controller factory to use.
  55       *
  56       * @param   CacheControllerFactoryInterface  $cacheControllerFactory  The cache controller factory to use.
  57       *
  58       * @return  void
  59       *
  60       * @since   4.2.0
  61       */
  62  	public function setCacheControllerFactory(CacheControllerFactoryInterface $cacheControllerFactory = null): void
  63      {
  64          $this->cacheControllerFactory = $cacheControllerFactory;
  65      }
  66  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer