[FEATURE] Add date parsing for schema based input conversion
This commit is contained in:
parent
c563dcf069
commit
8dbc5791d2
@ -52,8 +52,8 @@ trait ValidationTrait
|
|||||||
$flatten = new Flatten();
|
$flatten = new Flatten();
|
||||||
$schemaFlat = $flatten->flattenToArray($schema);
|
$schemaFlat = $flatten->flattenToArray($schema);
|
||||||
$typesList = [];
|
$typesList = [];
|
||||||
|
$formatsList = [];
|
||||||
foreach ($schemaFlat as $index => $row) {
|
foreach ($schemaFlat as $index => $row) {
|
||||||
if (substr($index, -5) == '.type') {
|
|
||||||
$dataIndex = preg_replace(
|
$dataIndex = preg_replace(
|
||||||
'/(\.)(properties\.|items\.)/',
|
'/(\.)(properties\.|items\.)/',
|
||||||
'$1',
|
'$1',
|
||||||
@ -65,15 +65,20 @@ trait ValidationTrait
|
|||||||
$dataIndex
|
$dataIndex
|
||||||
);
|
);
|
||||||
$dataIndex = preg_replace(
|
$dataIndex = preg_replace(
|
||||||
'/\.type$/',
|
'/\.(type|format)$/',
|
||||||
'',
|
'',
|
||||||
$dataIndex
|
$dataIndex
|
||||||
);
|
);
|
||||||
|
if (substr($index, -5) == '.type') {
|
||||||
$typesList[$dataIndex] = $row;
|
$typesList[$dataIndex] = $row;
|
||||||
}
|
}
|
||||||
|
if (substr($index, -7) == '.format') {
|
||||||
|
$formatsList[$dataIndex] = $row;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
foreach ($input as $index => $row) {
|
foreach ($input as $index => $row) {
|
||||||
$rowType = $typesList[$index];
|
$rowType = $typesList[$index];
|
||||||
|
$formatType = $formatsList[$index];
|
||||||
if (!$rowType) {
|
if (!$rowType) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -92,6 +97,16 @@ trait ValidationTrait
|
|||||||
if ($testResult === true || $testResult === false) {
|
if ($testResult === true || $testResult === false) {
|
||||||
$input[$index] = $testResult;
|
$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;
|
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