[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

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

   1  <?php
   2  /**
   3   * Joomla! Content Management System
   4   *
   5   * @copyright  (C) 2018 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  /**
  14   * Default factory for creating CacheController objects
  15   *
  16   * @since  4.0.0
  17   */
  18  class CacheControllerFactory implements CacheControllerFactoryInterface
  19  {
  20      /**
  21       * Method to get an instance of a cache controller.
  22       *
  23       * @param   string  $type     The cache object type to instantiate
  24       * @param   array   $options  Array of options
  25       *
  26       * @return  CacheController
  27       *
  28       * @since   4.0.0
  29       * @throws  \RuntimeException
  30       */
  31  	public function createCacheController($type = 'output', $options = array()): CacheController
  32      {
  33          if (!$type)
  34          {
  35              $type = 'output';
  36          }
  37  
  38          $type = strtolower(preg_replace('/[^A-Z0-9_\.-]/i', '', $type));
  39  
  40          $class = __NAMESPACE__ . '\\Controller\\' . ucfirst($type) . 'Controller';
  41  
  42          // The class should now be loaded
  43          if (!class_exists($class))
  44          {
  45              throw new \RuntimeException('Unable to load Cache Controller: ' . $type, 500);
  46          }
  47  
  48          return new $class($options);
  49      }
  50  }


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