mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-20 03:16:12 +00:00
add revisiondata to getBackups for config class
This commit is contained in:
parent
6a2f32dcd2
commit
da2c3c1b6f
@ -319,15 +319,30 @@ class Config extends Singleton
|
||||
|
||||
/**
|
||||
* return list of config backups
|
||||
* @param bool $fetchRevisionInfo fetch revision information and return detailed information. (key/value)
|
||||
* @return array list of backups
|
||||
*/
|
||||
public function getBackups()
|
||||
public function getBackups($fetchRevisionInfo = false)
|
||||
{
|
||||
$target_dir = dirname($this->config_file)."/backup/";
|
||||
if (file_exists($target_dir)) {
|
||||
$backups = glob($target_dir."config*.xml");
|
||||
// sort by date (descending)
|
||||
rsort($backups);
|
||||
return $backups;
|
||||
if (!$fetchRevisionInfo) {
|
||||
return $backups;
|
||||
} else {
|
||||
$result = array ();
|
||||
foreach ($backups as $filename) {
|
||||
// try to read backup info from xml
|
||||
$xmlNode = simplexml_load_file($filename, "SimpleXMLElement", LIBXML_NOERROR | LIBXML_ERR_NONE);
|
||||
if (isset($xmlNode->revision)) {
|
||||
$result[$filename] = $this->toArray($xmlNode->revision);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
return array();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user