Source of file ConfigManifestProxy.php
Size: 2,194 Bytes - Last Modified: 2021-12-23T10:53:06+00:00
/var/www/docs.ssmods.com/process/src/code/Proxy/ConfigManifestProxy.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 | <?php namespace LeKoala\DebugBar\Proxy; use SilverStripe\Config\Collections\CachedConfigCollection; class ConfigManifestProxy extends CachedConfigCollection { /** * @var CachedConfigCollection */ protected $parent; /** * @var array */ protected static $configCalls = []; /** * @var boolean */ protected $trackEmpty = false; /** * @param CachedConfigCollection $parent */ public function __construct(CachedConfigCollection $parent) { $this->parent = $parent; $this->collection = $this->parent->getCollection(); $this->cache = $this->parent->getCache(); $this->flush = $this->parent->getFlush(); $this->collectionCreator = $this->parent->getCollectionCreator(); } /** * Monitor calls made to get configuration during a request * * {@inheritDoc} */ public function get($class, $name = null, $excludeMiddleware = 0) { $result = parent::get($class, $name, $excludeMiddleware); // Only track not empty values by default if ($result || $this->trackEmpty) { if (!isset(self::$configCalls[$class][$name])) { self::$configCalls[$class][$name] = [ 'calls' => 0, 'result' => null ]; } self::$configCalls[$class][$name]['calls']++; self::$configCalls[$class][$name]['result'] = $result; } return $result; } /** * Return a list of all config calls made during the request, including how many times they were called * and the result * * @return array */ public static function getConfigCalls() { return self::$configCalls; } /** * Get the value of trackEmpty * * @return boolean */ public function getTrackEmpty() { return $this->trackEmpty; } /** * Set the value of trackEmpty * * @param boolean $trackEmpty * * @return self */ public function setTrackEmpty($trackEmpty) { $this->trackEmpty = $trackEmpty; return $this; } } |