-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
[BUG] Can't get EntityManager in Command class #697
Comments
Can you please try instead of using the |
Hi @sergix44, I'm having the same issue. I tried what you asked: MyCommand.phppublic function __construct(private readonly ParameterBagInterface $parameterBag)
{
parent::__construct();
} telegram.php$bot->onCommand('something', [MyCommand::class, 'handle']); This way it works. |
Sorry, I was on vacation so I didn't check it. Yes, everything works when using onCommand. Closing the issue |
However, I believe it is still a bug that you can't use a service container with registerCommand. If it is a feature, it needs to be documented |
Nutgram version
4.19.0
PHP version
8.3
Framework
Symfony 7
Cache driver
apcu
OS
Ubuntu
Dev environment
Docker
Describe the bug
I get this error if I try to get EM autowired:
Too few arguments to function App\Telegram\Command\SomeCommand::__construct(), 0 passed in /var/www/app/vendor/nutgram/nutgram/src/Handlers/Listeners/MessageListeners.php on line 44 and exactly 1 expected
This also does not work:
Nor this:
To Reproduce
Expected behavior
How to get EM in command?
Screenshots
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: