にsymfonyのサービス注入は、以下の技術を使用してアクションで私に利用可能:アクション
http://symfony.com/doc/current/service_container.html#fetching-and-using-services
public function submitAction (Request $request, \Swift_Mailer $mailer)
{
$mailer = $this->get('mailer');
var_dump($mailer);
}
これはエラーです:
Controller "AppBundle\Controller\QuoteController::submitAction()" requires that you provide a value for the "$mailer" argument. Either the argument is nullable and no null value has been provided, no default value has been provided or because there is a non optional argument after this one.
var_dump
はこれが空ではないことを私に伝えます - 私は最近Symfony 3.3.10にアップグレードし、services.ymlを以下のように変更しました:
services:
_defaults:
autowire: true
autoconfigure: true
public: true
私はそれがそうであったかどうか疑問に思っていました。しかし、コントローラがタグ付けされていないとリクエストがどのように注入されるのでしょうか? –
ちょうど情報のため、リクエストオブジェクトは常に特別なケースとして扱われており、新しいアクションインジェクション機能には直接関係していません。 symfonyはネストされたリクエストをサポートしており、アクションが現在のリクエストを受け取ることが重要であるため、リクエストは少しユニークです。 – Cerad