/** * Write the cachable settings from the run checks to a cache file for later reuse. * * @todo should cache only be written if all checks succeeded? * * @param boolean $run_was_successful whether or not the checks ran successfully */ protected function writeCache($run_was_successful) { $disable_caching = $this->input->getOption('no-cache'); if (!empty($disable_caching)) { return; } $cache_implementor = $this->config->getCacheImplementor(); $cache = new $cache_implementor(); if (!$cache instanceof ICache) { throw new \InvalidArgumentException('The given cache class "' . $cache_implementor . '" does not implement ICache.'); } $cache_params = new Parameters($this->config->get('cache', array())); $cache->setParameters($cache_params); // TODO use something like getenv('ENVIRONAUT_CACHE_DIR')? $cache_location = $this->input->getOption('cache-location'); if (!empty($cache_location)) { $cache->setLocation($cache_location); } $cache->addAll($this->report->getCachableSettings()); if ($cache->save()) { $this->output->writeln(PHP_EOL . 'Writing cachable settings to "<comment>' . $cache->getLocation() . '</comment>" for subsequent runs...<info>ok</info>.' . PHP_EOL); } else { $this->output->writeln(PHP_EOL . 'Writing cachable settings to "<comment>' . $cache->getLocation() . '</comment>" for subsequent runs...<error>FAILED</error>.' . PHP_EOL); } }