Added timestamp on configurations #1480

This commit is contained in:
Andy Miller 2017-05-17 12:11:48 -06:00
parent dd058155c8
commit cb36bdabdf
No known key found for this signature in database
GPG Key ID: E82B8D0EAB94EFB9
6 changed files with 40 additions and 1 deletions

View File

@ -5,6 +5,7 @@
* Added new `media` and `vardump` Twig functions
1. [](#improved)
* Put in various checks to ensure Exif is available before trying to use it
* Add timestamp to configuration settings [#1445](https://github.com/getgrav/grav/pull/1445)
1. [](#bugfix)
* Fix an issue saving YAML textarea fields in expert mode [#1480](https://github.com/getgrav/grav/pull/1480)

View File

@ -27,6 +27,11 @@ abstract class CompiledBase
*/
public $checksum;
/**
* @var string Timestamp of compiled configuration
*/
public $timestamp;
/**
* @var string Cache folder to be used.
*/
@ -59,9 +64,10 @@ abstract class CompiledBase
throw new \BadMethodCallException('Cache folder not defined.');
}
$this->path = $path ? rtrim($path, '\\/') . '/' : '';
$this->cacheFolder = $cacheFolder;
$this->files = $files;
$this->path = $path ? rtrim($path, '\\/') . '/' : '';
$this->timestamp = 0;
}
/**
@ -84,6 +90,16 @@ abstract class CompiledBase
*/
public function modified() {}
/**
* Get timestamp of compiled configuration
*
* @return int Timestamp of compiled configuration
*/
public function timestamp()
{
return $this->timestamp ?: time();
}
/**
* Load the configuration.
*
@ -196,6 +212,7 @@ abstract class CompiledBase
}
$this->createObject($cache['data']);
$this->timestamp = isset($cache['timestamp']) ? $cache['timestamp'] : 0;
$this->finalizeObject();

View File

@ -77,6 +77,7 @@ class CompiledConfig extends CompiledBase
protected function finalizeObject()
{
$this->object->checksum($this->checksum());
$this->object->timestamp($this->timestamp());
}
/**

View File

@ -38,6 +38,7 @@ class CompiledLanguages extends CompiledBase
protected function finalizeObject()
{
$this->object->checksum($this->checksum());
$this->object->timestamp($this->timestamp());
}

View File

@ -17,6 +17,7 @@ class Config extends Data
{
protected $checksum;
protected $modified = false;
protected $timestamp = 0;
public function key()
{
@ -41,6 +42,15 @@ class Config extends Data
return $this->modified;
}
public function timestamp($timestamp = null)
{
if ($timestamp !== null) {
$this->timestamp = $timestamp;
}
return $this->timestamp;
}
public function reload()
{
$grav = Grav::instance();

View File

@ -30,6 +30,15 @@ class Languages extends Data
return $this->modified;
}
public function timestamp($timestamp = null)
{
if ($timestamp !== null) {
$this->timestamp = $timestamp;
}
return $this->timestamp;
}
public function reformat()
{
if (isset($this->items['plugins'])) {