Skip to content

[Clock] Fix ClockAwareTrait usage #17772

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions components/clock.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ the default one during tests, you will have full control to set the "current tim
to any arbitrary date/time.

In order to use this component in your services, make their classes use the
:class:`Symfony\\Component\\Clock\\ClockAwareTrait` and add a ``ClockInterface``
typed-property ``$clock`` to their constructors.
:class:`Symfony\\Component\\Clock\\ClockAwareTrait`. Thanks to
:ref:`service autoconfiguration <services-autoconfigure>`, the ``setClock()`` method
of the trait will automatically be called by the service container.

If your application uses :ref:`service autoconfiguration <services-autoconfigure>`,
your services can now call the ``$this->now()`` method to get the current time::
You can now call the ``$this->now()`` method to get the current time::

namespace App\TimeUtils;

Expand Down