File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -114,11 +114,13 @@ the default one during tests, you will have full control to set the "current tim
114
114
to any arbitrary date/time.
115
115
116
116
In order to use this component in your services, make their classes use the
117
- :class: `Symfony\\ Component\\ Clock\\ ClockAwareTrait ` and add a ``ClockInterface ``
118
- typed-property ``$clock `` to their constructors.
119
-
120
- If your application uses :ref: `service autoconfiguration <services-autoconfigure >`,
121
- your services can now call the ``$this->now() `` method to get the current time::
117
+ :class: `Symfony\\ Component\\ Clock\\ ClockAwareTrait `. This trait defines the
118
+ ``ClockAwareTrait::setClock() `` method. Thanks to the ``#[Required] `` attribute
119
+ declared on this method and if your application uses :ref: `service autoconfiguration <services-autoconfigure >`,
120
+ ``ClockAwareTrait::setClock() `` will automatically be called by the service container,
121
+ injecting a clock implementation into the ``$clock `` property (also provided
122
+ by the trait). Your services can now call the ``$this->now() `` method to get the
123
+ current time::
122
124
123
125
namespace App\TimeUtils;
124
126
You can’t perform that action at this time.
0 commit comments