The vendor's code looks like this:
/**
* Create a new SendEmailsCommand instance.
*
* @param Store $store
*/
public function __construct(Store $store)
{
parent::__construct();
$this->store = $store;
}
But when I invoke this command with say php artisan mail:send
, where does the value of $store
come from? Is this what is meant by this cryptic documentation quote?
Note that we are able to inject any dependencies we need into the command's constructor. The Laravel service container will automatically inject all dependencies type-hinted in the constructor.
I see that Laravel (5.2) documentation on console commands seems to do a similar thing with an object called Drip
... https://laravel.com/docs/5.2/artisan#command-structure
Is Laravel taking upon itself to realize that there's a type-name given to the constructor, and it automagically instantiates a corresponding object instead of expecting your constructor to do so itself?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire