connect('config', [ 'dir' => CONFIG_PATH, 'humanReadable' => true ]); } return self::$singleton; } /** * Override the function to allow an additional header * * (non-PHPdoc) * @see common_persistence_PhpFileDriver::getContent() */ protected function getContent($key, $value) { $headerPath = $this->getHeaderPath($key); $header = !is_null($headerPath) && file_exists($headerPath) ? file_get_contents($headerPath) : $this->getDefaultHeader($key); return $header . PHP_EOL . "return " . common_Utils::toHumanReadablePhpString($value) . ";" . PHP_EOL; } /** * Generates a default header * * @param string $key * @return string */ private function getDefaultHeader($key) { return 'getHeaderPath($key) . PHP_EOL . ' */' . PHP_EOL; } /** * Returns the path to the expected header file * * @param string $key * @return string|NULL */ private function getHeaderPath($key) { $parts = explode('/', $key, 2); if (count($parts) >= 2) { list($extId, $configId) = $parts; $ext = common_ext_ExtensionsManager::singleton()->getExtensionById($extId); return $ext->getDir() . 'config/header/' . $configId . '.conf.php'; } else { return null; } } /** * (non-PHPdoc) * @see common_persistence_PhpFileDriver::getPath() */ protected function getPath($key) { $parts = explode('/', $key); $path = substr(parent::getPath(array_shift($parts)), 0, -4); foreach ($parts as $part) { $path .= DIRECTORY_SEPARATOR . $this->sanitizeReadableFileName($part); } return $path . '.conf.php'; } }