Skip to content

Commit 1fc1542

Browse files
Add doc about lockableTrait
1 parent 0816f2b commit 1fc1542

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

console/lockable_trait.rst

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

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

0 commit comments

Comments
 (0)