public function attachCache($cacheService) { static $mode, $collector, $hasAttachd = array(); if (in_array($cacheService, $hasAttachd)) { return; } $hasAttachd[] = $cacheService; if (!$this->shouldCollect('cache', false)) { return; } if (!is_string($cacheService)) { throw new \Exception('The parameter must be a cache service name.'); } if (!$mode) { $mode = $this->config->options->cache->get('mode', 0); } if (!$collector) { $mc = null; if ($this->hasCollector('messages')) { $mc = $this->getCollector('messages'); } $collector = new CacheCollector($mode, $mc); $this->addCollector($collector); } $backend = $this->di->get($cacheService); if ($backend instanceof Multiple || $backend instanceof Backend) { if ($this->shouldCollect('cache', false)) { $this->di->remove($cacheService); $self = $this; $this->di->set($cacheService, function () use($self, $backend, $collector) { return $self->createProxy(clone $backend, $collector); }); } } }
public function __construct(DI $di, $aggregate = true, $formatter = 'line') { $this->_di = $di; $this->_debugbar = $this->_di['debugbar']; $this->_formatter = strtolower($formatter); if ($di->has('log') && ($log = $di->get('log'))) { $debugbar_loger = new Debugbar($di['debugbar']); if ($log instanceof Adapter) { $di->remove('log'); $multiple = new Multiple(); $multiple->push(clone $log); $multiple->push($debugbar_loger); /** @var DI\Service $service */ $di->set('log', $multiple); } elseif ($log instanceof Multiple) { $log->push($debugbar_loger); } $this->_aggregate = $this->isAggregate($aggregate); } }
public function tearDown() { $this->di->getShared('eventsManager')->detachAll(); $this->di->remove('view'); }