From 1aab03d5113790f068f54ba224ac429fda9891d2 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Fri, 22 Mar 2024 09:58:55 +0100 Subject: [PATCH] [Console] Add doc about lockableTrait --- console/lockable_trait.rst | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/console/lockable_trait.rst b/console/lockable_trait.rst index 02f635f5788..19f30e86d96 100644 --- a/console/lockable_trait.rst +++ b/console/lockable_trait.rst @@ -43,4 +43,24 @@ that adds two convenient methods to lock and release commands:: } } +The LockableTrait will use the ``SemaphoreStore`` if available and will default +to ``FlockStore`` otherwise. You can override this behavior by setting +a ``$lockFactory`` property with your own lock factory:: + + // ... + use Symfony\Component\Console\Command\Command; + use Symfony\Component\Console\Command\LockableTrait; + use Symfony\Component\Lock\LockFactory; + + class UpdateContentsCommand extends Command + { + use LockableTrait; + + public function __construct(private LockFactory $lockFactory) + { + } + + // ... + } + .. _`locks`: https://en.wikipedia.org/wiki/Lock_(computer_science)