/** * Creates a cache config instance with the ability to write if required. * * @param bool $writer Unused. * @return cache_config_disabled|cache_config_writer */ public function create_config_instance($writer = false) { // We are always going to use the cache_config_disabled class for all regular request. // However if the code has requested the writer then likely something is changing and // we're going to need to interact with the config.php file. // In this case we will still use the cache_config_writer. $class = 'cache_config_disabled'; if ($writer) { // If the writer was requested then something is changing. $class = 'cache_config_writer'; } if (!array_key_exists($class, $this->configs)) { self::set_state(self::STATE_INITIALISING); if ($class === 'cache_config_disabled') { $configuration = $class::create_default_configuration(); } else { $configuration = false; if (!cache_config::config_file_exists()) { cache_config_writer::create_default_configuration(true); } } $this->configs[$class] = new $class(); $this->configs[$class]->load($configuration); } self::set_state(self::STATE_READY); // Return the instance. return $this->configs[$class]; }