cacheFile = $file; $this->parser = $parser; $this->core = $core; $this->registry = $parser->parse($file); } protected function exists($name) { return isset($this->registry[$name]); } public function flushAll() { foreach ($this->registry as $cacheKey => $service_name) { $this->get($cacheKey, $service_name)->getDriver()->deleteAll(); } return $this; } public function get($cacheKey, $service_name) { if (!$this->exists($cacheKey)) { $this->registry[$cacheKey] = $service_name; } try { $configuration = $this->core->getConfiguration()->getService($service_name); } catch (\Exception $e) { $configuration = new \Symfony\Component\DependencyInjection\ParameterBag\ParameterBag( array('type' => 'Cache\\ArrayCache') ); } $driver = Builder::create($this->core, $service_name, $configuration); if ($this->hasChange($cacheKey, $service_name)) { $driver->getDriver()->deleteAll(); $this->save($cacheKey, $service_name); } return $driver; } protected function hasChange($name, $driver) { return $this->exists($name) ? $this->registry[$name] !== $driver : true; } protected function save($name, $driver) { $date = new \DateTime(); $this->registry[$name] = $driver; $datas = sprintf("#LastUpdate: %s\n", $date->format(DATE_ISO8601)) . $this->parser->dump($this->registry); file_put_contents($this->cacheFile->getPathname(), $datas); } }