Catchable Fatal Error: Argument 1 passed to MailerBundle\Controller\EmailController::__construct() must be an instance of MailerBundle\Sender\EmailSender, none given, called in C:\xampp1\htdocs\murkatest\var\cache\dev\classes.php on line 2084 and defined
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class MailerExtension extends Extension
{
/**
* Loads a specific configuration.
*
* @param array $configs An array of configuration values
* @param ContainerBuilder $container A ContainerBuilder instance
*
* @throws \InvalidArgumentException When provided tag is not defined in this extension
*/
public function load(array $configs, ContainerBuilder $container)
{
$container->setDefinition('emailsender', new Definition('MailerBundle\Sender\EmailSender',[
new Reference('swiftmailer.mailer'),
new Reference('swiftmailer.transport')]));
$container->setDefinition('emailnotifier', new Definition('MailerBundle\Controller\EmailController',[
new Reference('emailsender')]));
}
}
use MailerBundle\Entity\Notification;
use MailerBundle\Sender\EmailSender;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
class EmailController extends Controller
{
/**
* var EmailSender
*/
private $sender;
/**
* EmailController constructor.
* @param EmailSender $sender
*/
public function __construct(EmailSender $sender)
{
$this->sender = $sender;
}
/**
* return \Symfony\Component\HttpFoundation\Response
*/
public function indexAction()
{
return $this->render('MailerBundle:Email:index.html.twig');
}
/**
* @param Request $request
* return \Symfony\Component\HttpFoundation\Response
*/
public function sendAction(Request $request)
{
$notification = new Notification();
$user = $this->get('security.token_storage')->getToken()->getUser();
$notification->setBody($request->request->get('subject'), $user->getUsername());
$notification->setSubject($request->request->get('body'));
Пока дошел до этого: "'swiftmailer.mailer.default'" is not a valid class name for the "swiftmailer.mailer" service. Хотя 'swiftmailer.mailer.default это алиас для swiftmailer.mailer
Хоть что то поменялось:
The service "swiftmailer.mailer" has a dependency on a non-existent parameter "swiftmailer.mailer". Did you mean one of these: "swiftmailer.class", "swiftmailer.mailer.default.transport.name", "swiftmailer.mailer.default.delivery.enabled", "swiftmailer.mailer.default.transport.smtp.encryption", "swiftmailer.mailer.default.transport.smtp.port", "swiftmailer.mailer.default.transport.smtp.host", "swiftmailer.mailer.default.transport.smtp.username", "swiftmailer.mailer.default.transport.smtp.password", "swiftmailer.mailer.default.transport.smtp.auth_mode", "swiftmailer.mailer.default.transport.smtp.timeout", "swiftmailer.mailer.default.transport.smtp.source_ip", "swiftmailer.mailer.default.spool.enabled", "swiftmailer.mailer.default.plugin.impersonate", "swiftmailer.mailer.default.single_address", "swiftmailer.mailers"?
hello:
path: /hello
defaults: { _controller: app.hello_controller:indexAction } ?