[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 * This file is part of the DebugBar package. 4 * 5 * (c) 2013 Maxime Bouroumeau-Fuseau 6 * 7 * For the full copyright and license information, please view the LICENSE 8 * file that was distributed with this source code. 9 */ 10 11 namespace DebugBar\Bridge; 12 13 use CacheCache\Cache; 14 use CacheCache\LoggingBackend; 15 use Monolog\Logger; 16 17 /** 18 * Collects CacheCache operations 19 * 20 * http://maximebf.github.io/CacheCache/ 21 * 22 * Example: 23 * <code> 24 * $debugbar->addCollector(new CacheCacheCollector(CacheManager::get('default'))); 25 * // or 26 * $debugbar->addCollector(new CacheCacheCollector()); 27 * $debugbar['cache']->addCache(CacheManager::get('default')); 28 * </code> 29 */ 30 class CacheCacheCollector extends MonologCollector 31 { 32 protected $logger; 33 34 /** 35 * CacheCacheCollector constructor. 36 * @param Cache|null $cache 37 * @param Logger|null $logger 38 * @param bool $level 39 * @param bool $bubble 40 */ 41 public function __construct(Cache $cache = null, Logger $logger = null, $level = Logger::DEBUG, $bubble = true) 42 { 43 parent::__construct(null, $level, $bubble); 44 45 if ($logger === null) { 46 $logger = new Logger('Cache'); 47 } 48 $this->logger = $logger; 49 50 if ($cache !== null) { 51 $this->addCache($cache); 52 } 53 } 54 55 /** 56 * @param Cache $cache 57 */ 58 public function addCache(Cache $cache) 59 { 60 $backend = $cache->getBackend(); 61 if (!($backend instanceof LoggingBackend)) { 62 $backend = new LoggingBackend($backend, $this->logger); 63 } 64 $cache->setBackend($backend); 65 $this->addLogger($backend->getLogger()); 66 } 67 68 /** 69 * @return string 70 */ 71 public function getName() 72 { 73 return 'cache'; 74 } 75 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |