Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX] Respect DateTimeImmutable in Extbase
The DateTimeConverter and DataMapper of Extbase now checks for DateTimeInterface, and can thus handle DateTimeImmutable, otherwise Extbase cannot handle these kinds of formats. Resolves: #72053 Releases: master Change-Id: Ic922e715a31e1d02f5f6daa18415e8376788da8b Reviewed-on: https://review.typo3.org/57388 Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Benni Mack <benni@typo3.org> Tested-by: Benni Mack <benni@typo3.org> Reviewed-by: Georg Ringer <georg.ringer@gmail.com> Tested-by: Georg Ringer <georg.ringer@gmail.com>
- Loading branch information
1 parent
2130b34
commit aabe5f7
Showing
7 changed files
with
208 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
...tional/Fixtures/Extensions/blog_example/Classes/Domain/Model/DateTimeImmutableExample.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
namespace ExtbaseTeam\BlogExample\Domain\Model; | ||
|
||
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; | ||
|
||
class DateTimeImmutableExample extends AbstractEntity | ||
{ | ||
|
||
/** | ||
* A datetimeImmutable stored in a text field | ||
* | ||
* @var \DateTimeImmutable | ||
*/ | ||
protected $datetimeImmutableText; | ||
|
||
/** | ||
* A datetime stored in an integer field | ||
* | ||
* @var \DateTimeImmutable | ||
*/ | ||
protected $datetimeImmutableInt; | ||
|
||
/** | ||
* A datetime stored in a datetime field | ||
* | ||
* @var \DateTimeImmutable | ||
*/ | ||
protected $datetimeImmutableDatetime; | ||
|
||
/** | ||
* @return \DateTimeImmutable | ||
*/ | ||
public function getDatetimeImmutableText(): \DateTimeImmutable | ||
{ | ||
return $this->datetimeImmutableText; | ||
} | ||
|
||
/** | ||
* @param \DateTimeImmutable $datetimeImmutableText | ||
*/ | ||
public function setDatetimeImmutableText(\DateTimeImmutable $datetimeImmutableText) | ||
{ | ||
$this->datetimeImmutableText = $datetimeImmutableText; | ||
} | ||
|
||
/** | ||
* @return \DateTimeImmutable | ||
*/ | ||
public function getDatetimeImmutableInt(): \DateTimeImmutable | ||
{ | ||
return $this->datetimeImmutableInt; | ||
} | ||
|
||
/** | ||
* @param \DateTimeImmutable $datetimeImmutableInt | ||
*/ | ||
public function setDatetimeImmutableInt(\DateTimeImmutable $datetimeImmutableInt) | ||
{ | ||
$this->datetimeImmutableInt = $datetimeImmutableInt; | ||
} | ||
|
||
/** | ||
* @return \DateTimeImmutable | ||
*/ | ||
public function getDatetimeImmutableDatetime(): \DateTimeImmutable | ||
{ | ||
return $this->datetimeImmutableDatetime; | ||
} | ||
|
||
/** | ||
* @param \DateTimeImmutable $datetimeImmutableDatetime | ||
*/ | ||
public function setDatetimeImmutableDatetime(\DateTimeImmutable $datetimeImmutableDatetime) | ||
{ | ||
$this->datetimeImmutableDatetime = $datetimeImmutableDatetime; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...s/blog_example/Configuration/TCA/tx_blogexample_domain_model_datetimeimmutableexample.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
return [ | ||
'ctrl' => [ | ||
'title' => 'DateTimeImmutable Example', | ||
'label' => 'title', | ||
], | ||
'columns' => [ | ||
'datetime_immutable_text' => [ | ||
'exclude' => 1, | ||
'label' => 'eval=datetime, db=text', | ||
'config' => [ | ||
'type' => 'input', | ||
'renderType' => 'inputDateTime', | ||
'eval' => 'datetime', | ||
] | ||
], | ||
'datetime_immutable_int' => [ | ||
'exclude' => 1, | ||
'label' => 'eval=datetime, db=int', | ||
'config' => [ | ||
'type' => 'input', | ||
'renderType' => 'inputDateTime', | ||
'eval' => 'datetime', | ||
] | ||
], | ||
'datetime_immutable_datetime' => [ | ||
'exclude' => 1, | ||
'label' => 'eval=datetime, db=datetime', | ||
'config' => [ | ||
'dbType' => 'datetime', | ||
'type' => 'input', | ||
'renderType' => 'inputDateTime', | ||
'eval' => 'datetime', | ||
] | ||
] | ||
], | ||
'types' => [ | ||
'1' => ['showitem' => 'datetime_text', 'datetime_int', 'datetime_datetime'] | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters