Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 678b0cd

Browse files
committed
feature #44125 Add a setter on DateTimeNormalizer to change the default context at runtime (Seldaek)
This PR was merged into the 5.4 branch. Discussion ---------- Add a setter on DateTimeNormalizer to change the default context at runtime | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | yes <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> Allows changing the default once the default timezone is known, if you do have a per-user default timezone which is only known at runtime and can't be baked in the container. Commits ------- 6852ca7 Add a setter on DateTimeNormalizer to change the default context at runtime
2 parents 6d76dfe + 6852ca7 commit 678b0cd

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ class DateTimeNormalizer implements NormalizerInterface, DenormalizerInterface,
3838
];
3939

4040
public function __construct(array $defaultContext = [])
41+
{
42+
$this->setDefaultContext($defaultContext);
43+
}
44+
45+
public function setDefaultContext(array $defaultContext): void
4146
{
4247
$this->defaultContext = array_merge($this->defaultContext, $defaultContext);
4348
}

0 commit comments

Comments
 (0)