You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature #48098 [HttpKernel] Resolve DateTime value using the Clock (GromNaN)
This PR was merged into the 6.3 branch.
Discussion
----------
[HttpKernel] Resolve DateTime value using the Clock
| Q | A
| ------------- | ---
| Branch? | 6.3
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | TODO
In order to mock the current time in functional test cases by injecting a `Symfony\Component\Clock\MockClock` as `clock` service. This is necessary when a `DateTimeInterface` argument is not nullable and we expect the current date time by default.
Example when 2 routes are configured on the same controller with an optional parameter.
```php
class TvGridController
{
#[Route('/', name: 'prime_now')]
#[Route('/{date}', name: 'prime_date']
public function prime(\DateTimeInterface $date)
{
return new Response('Grid for date: '.$date->format('Y-m-d'));
}
}
```
Commits
-------
4917528 Resolve DateTime value using the clock
Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,7 @@ CHANGELOG
7
7
* Deprecate parameters `container.dumper.inline_factories` and `container.dumper.inline_class_loader`, use `.container.dumper.inline_factories` and `.container.dumper.inline_class_loader` instead
8
8
*`FileProfilerStorage` removes profiles automatically after two days
9
9
* Add `#[HttpStatus]` for defining status codes for exceptions
10
+
* Use an instance of `Psr\Clock\ClockInterface` to generate the current date time in `DateTimeValueResolver`
0 commit comments