Project

General

Profile

Actions

Bug #95396

closed

JsonView missing support for DateTimeImmutable

Added by Oliver Eglseder about 3 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Extbase
Target version:
Start date:
2021-09-29
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
11
PHP Version:
Tags:
Complexity:
no-brainer
Is Regression:
Sprint Focus:

Description

JsonView does "support" DateTime, because it automatically transforms it by formatting to ATOM.
The variant DateTimeImmutable is not formatted as ATOM, instead its properties will be listed. (offset and timestamp).

Controller code:

    public function listAction(): void
    {
        if ($this->view instanceof JsonView) {
            $this->view->setVariablesToRender(['publications']);
            $this->view->setConfiguration(
                [
                    'publications' => [
                        '_descendAll' => [
                            '_only' => [
                                'publishingDate',
                            ],
                            '_descend' => [
                                'publishingDate' => [],
                            ],
                        ],
                    ],
                ]
            );
        }
        $this->view->assign('publications', $this->publicationRepository->findAll());
    }

Actual:

[
  {
    "publishingDate": {
      "offset": 0,
      "timestamp": 1631119140
    }
  }
]

Expected:

[
  {
    "publishingDate": "2021-09-08T16:39:00+00:00" 
  }
]

Actions #1

Updated by Gerrit Code Review about 3 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/71347

Actions #2

Updated by Gerrit Code Review about 3 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/71347

Actions #3

Updated by Gerrit Code Review about 3 years ago

Patch set 1 for branch 10.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/71377

Actions #4

Updated by Anonymous about 3 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #5

Updated by Benni Mack about 3 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF