Source of file ConfigManifestProxy.php
Size: 2,324 Bytes - Last Modified: 2021-12-23T10:00:22+00:00
/var/www/docs.ssmods.com/process/src/code/Proxy/ConfigManifestProxy.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 | <?php namespace LeKoala\DebugBar\Proxy; use LeKoala\DebugBar\DebugBar; use SilverStripe\Config\Collections\CachedConfigCollection; class ConfigManifestProxy extends CachedConfigCollection implements ProxyConfigCollectionInterface { /** * @var CachedConfigCollection */ protected $parent; /** * @var array */ protected $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(); $this->setTrackEmpty(DebugBar::config()->config_track_empty); } /** * 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($this->configCalls[$class][$name])) { $this->configCalls[$class][$name] = [ 'calls' => 0, 'result' => null ]; } $this->configCalls[$class][$name]['calls']++; $this->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 function getConfigCalls() { return $this->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; } } |