@@ -159,22 +159,23 @@ this behavior by using the ``lock`` key like:
159159 Locking a Resource
160160------------------
161161
162- To lock the default resource, autowire the lock using
163- :class: `Symfony\\ Component\\ Lock\\ LockInterface ` (service id ``lock ``)::
162+ To lock the default resource, autowire the lock factory using
163+ :class: `Symfony\\ Component\\ Lock\\ LockFactory ` (service id ``lock.factory ``)::
164164
165165 // src/Controller/PdfController.php
166166 namespace App\Controller;
167167
168168 use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
169- use Symfony\Component\Lock\LockInterface ;
169+ use Symfony\Component\Lock\LockFactory ;
170170
171171 class PdfController extends AbstractController
172172 {
173173 /**
174174 * @Route("/download/terms-of-use.pdf")
175175 */
176- public function downloadPdf(LockInterface $lock , MyPdfGeneratorService $pdf)
176+ public function downloadPdf(LockFactory $factory , MyPdfGeneratorService $pdf)
177177 {
178+ $lock = $factory->createLock('pdf-creation');
178179 $lock->acquire(true);
179180
180181 // heavy computation
@@ -193,6 +194,11 @@ To lock the default resource, autowire the lock using
193194 same lock, inject the ``LockFactory `` instead to create a separate lock
194195 instance for each service.
195196
197+ .. deprecated :: 5.2
198+
199+ The ``LockInterface `` service and ``lock `` alias are deprecated since
200+ Symfony 5.2.
201+
196202Locking a Dynamic Resource
197203--------------------------
198204
@@ -273,18 +279,20 @@ provides :ref:`named lock <reference-lock-resources-name>`::
273279 ],
274280 ]);
275281
276- Each name becomes a service where the service id suffixed by the name of the
277- lock (e.g. ``lock.invoice ``). An autowiring alias is also created for each lock
278- using the camel case version of its name suffixed by ``Lock `` - e.g. ``invoice ``
279- can be injected automatically by naming the argument ``$invoiceLock `` and
280- type-hinting it with :class: `Symfony\\ Component\\ Lock\\ LockInterface `.
281-
282- Symfony also provide a corresponding factory and store following the same rules
283- (e.g. ``invoice `` generates a ``lock.invoice.factory `` and
284- ``lock.invoice.store ``, both can be injected automatically by naming
285- respectively ``$invoiceLockFactory `` and ``$invoiceLockStore `` and type-hinted
286- with :class: `Symfony\\ Component\\ Lock\\ LockFactory ` and
287- :class: `Symfony\\ Component\\ Lock\\ PersistingStoreInterface `)
282+ Each name becomes a service where the service id is part of the name of the
283+ lock (e.g. ``lock.invoice.factory ``). An autowiring alias is also created for
284+ each lock using the camel case version of its name suffixed by ``LockFactory ``
285+ - e.g. ``invoice `` can be injected automatically by naming the argument
286+ ``$invoiceLockFactory `` and type-hinting it with
287+ :class: `Symfony\\ Component\\ Lock\\ LockFactory `.
288+
289+ .. deprecated :: 5.2
290+
291+ The services for ``LockInterface `` (ie. ``lock ``, ``lock.invoice ``,
292+ ``LockInterface $invoiceLock ``) and ``PersistingStoreInterface `` (ie.
293+ ``lock.store ``, ``lock.invoice.store ``, ``PersistingStoreInterface
294+ $invoiceLockStore ``) are deprecated Symfony 5.2.
295+
288296
289297Blocking Store
290298--------------
0 commit comments