@@ -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
@@ -273,18 +274,12 @@ provides :ref:`named lock <reference-lock-resources-name>`::
273274 ],
274275 ]);
275276
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 `)
277+ Each name becomes a service where the service id is part of the name of the
278+ lock (e.g. ``lock.invoice.factory ``). An autowiring alias is also created for
279+ each lock using the camel case version of its name suffixed by ``LockFactory ``
280+ - e.g. ``invoice `` can be injected automatically by naming the argument
281+ ``$invoiceLockFactory `` and type-hinting it with
282+ :class: `Symfony\\ Component\\ Lock\\ LockFactory `.
288283
289284Blocking Store
290285--------------
0 commit comments