*/
public function getMeta(string $name, bool $getLayout = FALSE): ?array {
$defn = [];
+ $mtime = NULL;
$jsonFile = $this->findFilePath($name, self::METADATA_JSON);
$htmlFile = $this->findFilePath($name, self::LAYOUT_FILE);
// Json takes priority because local overrides are always saved in that format.
if ($jsonFile !== NULL) {
$defn = json_decode(file_get_contents($jsonFile), 1);
+ $mtime = filemtime($jsonFile);
}
// Extensions may provide afform definitions in php files
else {
$phpFile = $this->findFilePath($name, self::METADATA_PHP);
if ($phpFile !== NULL) {
$defn = include $phpFile;
+ $mtime = filemtime($phpFile);
}
}
if ($htmlFile !== NULL) {
+ $mtime = max($mtime, filemtime($htmlFile));
if ($getLayout) {
// If the defn file included a layout, the html file overrides
$defn['layout'] = file_get_contents($htmlFile);
return NULL;
}
$defn['name'] = $name;
+ $defn['modified_date'] = date('Y-m-d H:i:s', $mtime);
return $defn;
}
'data_type' => 'Array',
'description' => 'HTML form layout; format is controlled by layoutFormat param',
],
+ [
+ 'name' => 'modified_date',
+ 'title' => E::ts('Date Modified'),
+ 'data_type' => 'Timestamp',
+ 'readonly' => TRUE,
+ ],
];
// Calculated fields returned by get action
if ($self->getAction() === 'get') {
$this->assertEquals($this->formName, $result['name']);
$this->assertArrayNotHasKey('directive_name', $result);
$this->assertArrayNotHasKey('has_base', $result);
+ // Check modified date is reasonable
+ $this->assertGreaterThan('2023-01-01 12:00:00', $result['modified_date']);
+ // Hopefully this test won't need updating for the next 2000 years or so...
+ $this->assertLessThan('4000-01-01 12:00:00', $result['modified_date']);
// Select * should also return regular fields only
$result = Afform::get()