Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Console] Add support for invokable commands in LockableTrait #60024

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 24, 2025

Conversation

yceruto
Copy link
Member

@yceruto yceruto commented Mar 23, 2025

Q A
Branch? 7.3
Bug fix? no
New feature? yes
Deprecations? no
Issues -
License MIT

This enables invokable commands to use LockableTrait without extending the Command class:

use Symfony\Component\Console\Command\LockableTrait;

#[AsCommand(name: 'foo:lock')]
class FooLockCommand
{
    use LockableTrait;

    public function __invoke(): int
    {
        if (!$this->lock()) {
            return Command::FAILURE;
        }

        // exclusive logic starts here...

        $this->release();

        return Command::SUCCESS;
    }
}

Ref: https://symfony.com/doc/current/console/lockable_trait.html

src/Symfony/Component/Console/CHANGELOG.md Outdated Show resolved Hide resolved
@fabpot fabpot force-pushed the lockable_invokable_command branch from e1521dd to 5595a32 Compare March 24, 2025 07:55
@fabpot
Copy link
Member

fabpot commented Mar 24, 2025

Thank you @yceruto.

@fabpot fabpot merged commit cf5b2f0 into symfony:7.3 Mar 24, 2025
3 of 4 checks passed
@yceruto yceruto deleted the lockable_invokable_command branch March 24, 2025 11:52
@fabpot fabpot mentioned this pull request May 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.