AcMailer\Controller\Plugin\Factory\SendMailPluginAbstractFactory::__invoke PHP Method

__invoke() public method

Create an object
public __invoke ( Interop\Container\ContainerInterface $container, string $requestedName, array $options = null ) : object
$container Interop\Container\ContainerInterface
$requestedName string
$options array
return object
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
    {
        $specificServiceName = $this->getSpecificServiceName($requestedName);
        /** @var MailServiceInterface $mailService */
        $mailService = $container->get(sprintf('%s.%s.%s', self::ACMAILER_PART, MailServiceAbstractFactory::SPECIFIC_PART, $specificServiceName));
        return new SendMailPlugin($mailService);
    }

Usage Example

 public function testCreateServiceWithName()
 {
     $sm = $this->createServiceManager();
     $mailServiceName = sprintf('%s.%s.%s', MailServiceAbstractFactory::ACMAILER_PART, MailServiceAbstractFactory::SPECIFIC_PART, 'concrete');
     $sm->setService($mailServiceName, new MailServiceMock());
     $this->assertInstanceOf(SendMailPlugin::class, $this->factory->__invoke($sm, 'sendMailConcrete'));
 }