-
-
Notifications
You must be signed in to change notification settings - Fork 324
Support for invokable objects in Container::call() #185
Copy link
Copy link
Closed
Labels
Milestone
Description
I know this is future compatibility feature (PHP 5.4), but I cannot use a object that implements the method __invoke in the container->call method. Now it throws an exception.
Example:
class SendMailAction
{
private $mailer;
public function __construct(MailerInterface $mailer)
{
$this->mailer = $mailer;
}
public function __invoke($sender, $recipient, $subject, $content)
{
$message = $this->mailer->compose($sender, $recipient, $subject, $content);
return $this->mailer->send($message);
}
}
$container->call(
$container->make(SendMailAction::class),
[
'sender' => '[email protected]',
'recipient' => '[email protected]',
'subject' => 'Testing',
'content' => 'This is a test message'
]
);Reactions are currently unavailable