コード例 #1
0
 /**
  * Create service with name
  *
  * @param ServiceLocatorInterface $serviceLocator
  * @param $name
  * @param $requestedName
  * @return mixed
  */
 public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
 {
     $config = $this->getConfig($serviceLocator)[$requestedName];
     $defaultSender = isset($config['default_sender']) ? $config['default_sender'] : null;
     $aliasSender = isset($config['alias_sender']) ? $config['alias_sender'] : null;
     $transport = Factory::create($config['transport']);
     $serviceClient = new MailService($transport, $defaultSender);
     $serviceClient->setAdditionalInfo(isset($config['additional_info']) ? $config['additional_info'] : []);
     return $serviceClient;
 }
コード例 #2
0
ファイル: FactoryTest.php プロジェクト: ripaclub/zf2-mailman
 public function testCreateWithoutExistingOptionsClassShouldThrowDomainException()
 {
     $this->setExpectedException('\\MailMan\\Exception\\DomainException', sprintf('%s expects the "options" attribute to resolve to an existing class; received "%s"', 'MailMan\\Transport\\Factory::create', 'Zend\\Mail\\Transport\\InMemoryOptions'));
     $input = ['type' => 'inmemory', 'options' => ['opt1' => 'value1']];
     $this->factory->create($input);
 }