Skip to content

Commit 3f816d4

Browse files
committed
minor #19697 [Console] Add doc about lockableTrait (VincentLanglet)
This PR was squashed before being merged into the 7.1 branch. Discussion ---------- [Console] Add doc about lockableTrait Closes #19688 Commits ------- 1aab03d [Console] Add doc about lockableTrait
2 parents f1b3164 + 1aab03d commit 3f816d4

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

console/lockable_trait.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,24 @@ that adds two convenient methods to lock and release commands::
4343
}
4444
}
4545

46+
The LockableTrait will use the ``SemaphoreStore`` if available and will default
47+
to ``FlockStore`` otherwise. You can override this behavior by setting
48+
a ``$lockFactory`` property with your own lock factory::
49+
50+
// ...
51+
use Symfony\Component\Console\Command\Command;
52+
use Symfony\Component\Console\Command\LockableTrait;
53+
use Symfony\Component\Lock\LockFactory;
54+
55+
class UpdateContentsCommand extends Command
56+
{
57+
use LockableTrait;
58+
59+
public function __construct(private LockFactory $lockFactory)
60+
{
61+
}
62+
63+
// ...
64+
}
65+
4666
.. _`locks`: https://en.wikipedia.org/wiki/Lock_(computer_science)

0 commit comments

Comments
 (0)