[FEATURE] Add date parsing for schema based input conversion
This commit is contained in:
parent
c563dcf069
commit
8dbc5791d2
@ -52,28 +52,33 @@ trait ValidationTrait
|
||||
$flatten = new Flatten();
|
||||
$schemaFlat = $flatten->flattenToArray($schema);
|
||||
$typesList = [];
|
||||
$formatsList = [];
|
||||
foreach ($schemaFlat as $index => $row) {
|
||||
$dataIndex = preg_replace(
|
||||
'/(\.)(properties\.|items\.)/',
|
||||
'$1',
|
||||
$index
|
||||
);
|
||||
$dataIndex = preg_replace(
|
||||
'/^properties\./',
|
||||
'',
|
||||
$dataIndex
|
||||
);
|
||||
$dataIndex = preg_replace(
|
||||
'/\.(type|format)$/',
|
||||
'',
|
||||
$dataIndex
|
||||
);
|
||||
if (substr($index, -5) == '.type') {
|
||||
$dataIndex = preg_replace(
|
||||
'/(\.)(properties\.|items\.)/',
|
||||
'$1',
|
||||
$index
|
||||
);
|
||||
$dataIndex = preg_replace(
|
||||
'/^properties\./',
|
||||
'',
|
||||
$dataIndex
|
||||
);
|
||||
$dataIndex = preg_replace(
|
||||
'/\.type$/',
|
||||
'',
|
||||
$dataIndex
|
||||
);
|
||||
$typesList[$dataIndex] = $row;
|
||||
}
|
||||
if (substr($index, -7) == '.format') {
|
||||
$formatsList[$dataIndex] = $row;
|
||||
}
|
||||
}
|
||||
foreach ($input as $index => $row) {
|
||||
$rowType = $typesList[$index];
|
||||
$formatType = $formatsList[$index];
|
||||
if (!$rowType) {
|
||||
continue;
|
||||
}
|
||||
@ -92,6 +97,16 @@ trait ValidationTrait
|
||||
if ($testResult === true || $testResult === false) {
|
||||
$input[$index] = $testResult;
|
||||
}
|
||||
case 'string':
|
||||
switch ($formatType) {
|
||||
case 'date':
|
||||
$row = \DateTime::createFromFormat(
|
||||
'Y-m-d H:i:s',
|
||||
$row . ' 00:00:00',
|
||||
);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $input;
|
||||
|
33
composer.json.orig
Normal file
33
composer.json.orig
Normal file
@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "cjel/templates-aide",
|
||||
"type": "typo3-cms-extension",
|
||||
"description": "",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Philipp Dieter",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
<<<<<<< HEAD
|
||||
"typo3/cms-core": "8.7.0 - 9.5.99",
|
||||
"sarhan/php-flatten": "^4.0"
|
||||
=======
|
||||
"typo3/cms-core": "8.7.0 - 10.99.99"
|
||||
>>>>>>> 4a4b809d13bd33b85d84f03eba5edb603d74abfb
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Cjel\\TemplatesAide\\": "Classes"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Cjel\\TemplatesAide\\Tests\\": "Tests"
|
||||
}
|
||||
},
|
||||
"replace": {
|
||||
"templates_aide": "self.version",
|
||||
"typo3-ter/templates-aide": "self.version"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user