Source of file DeltaConfigManifestProxy.php
Size: 2,174 Bytes - Last Modified: 2021-12-23T10:00:22+00:00
/var/www/docs.ssmods.com/process/src/code/Proxy/DeltaConfigManifestProxy.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 | <?php namespace LeKoala\DebugBar\Proxy; use LeKoala\DebugBar\DebugBar; use SilverStripe\Config\Collections\DeltaConfigCollection; class DeltaConfigManifestProxy extends DeltaConfigCollection implements ProxyConfigCollectionInterface { /** * @var DeltaConfigCollection */ protected $parent; /** * @var array */ protected $configCalls = []; /** * @var boolean */ protected $trackEmpty = false; public static function createFromOriginal(DeltaConfigCollection $collection) { $newCollection = static::createFromCollection($collection, $collection->getDeltaMiddleware()->getDisableFlag()); $newCollection->setTrackEmpty(DebugBar::config()->config_track_empty); return $newCollection; } /** * 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; } } |