-
Notifications
You must be signed in to change notification settings - Fork 669
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
Dependency Injection in commands constructors #53
Conversation
Just trying to follow this. You want to use Laravel's IOC container so that you get automatic dependency injection when you create a class for a command? So that <?php
namespace App\Telegram\Bot\commands;
use App\Telegram\Bot\BotCommand;
class start extends BotCommand
{
protected $demo;
protected $example;
public function __construct(Demo $demo, Example $example)
{
$this->demo = $demo;
$this->example = $example;
}
protected $name = "start";
protected $description = "start Description";
public function handle($arguments)
{
}
} Demo and Example are resolved for you automatically? |
Yes, exactly. But I've just discovered that I forgot to check if the constructor is available. I'll fix asap.
|
Hey @antoniomadonna Thanks for opening a PR. I appreciate your contribution. I'll test this once you push a fix and merge it if i don't find any issues. Looks good to me. 👍 |
ty @irazasyed I've fixed the issue :) |
@antoniomadonna Can you please rebase as per the latest changes in master branch? Also, Please send a separate PR for each change (In this case, Tests should be in a separate PR). You have two different things pushed in one. Please update. Thanks! |
Use Laravel Container Class to resolve commands type hinted dependencies.
@irazasyed sorry I'm new to contributing, this PR should be ok now, I'm going to submit the tests asap |
Dependency Injection in commands constructors
@antoniomadonna No problem. Thanks for separating the PRs and for all the contributions :) |
Use Laravel Container Class to resolve commands type hinted dependencies.