本文整理匯總了PHP中Zend\Mail\Transport\Smtp::setConnection方法的典型用法代碼示例。如果您正苦於以下問題:PHP Smtp::setConnection方法的具體用法?PHP Smtp::setConnection怎麽用?PHP Smtp::setConnection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend\Mail\Transport\Smtp
的用法示例。
在下文中一共展示了Smtp::setConnection方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: setUp
public function setUp()
{
$this->transport = new Smtp();
$this->connection = new SmtpProtocolSpy();
$this->transport->setConnection($this->connection);
}
示例2: getServiceConfig
/**
* Load the services.
*
* @return array
*/
public function getServiceConfig()
{
return array('initializers' => array('DataSourceAwareInterface' => function ($instance, $sm) {
if ($instance instanceof Lib\DataSourceAwareInterface) {
$instance->setDataSource($sm->get('PDO'));
}
}, 'QueueConnectionAwareInterface' => function ($instance, $sm) {
if ($instance instanceof QueueConnectionAwareInterface) {
$i = $sm->get('Stjornvisi\\Lib\\QueueConnectionFactory');
$instance->setQueueConnectionFactory($sm->get('Stjornvisi\\Lib\\QueueConnectionFactory'));
}
}, 'LoggerAwareInterface' => function ($instance, $sm) {
if ($instance instanceof LoggerAwareInterface) {
$instance->setLogger($sm->get('Logger'));
}
}, 'DataStoreInterface' => function ($instance, $sm) {
if ($instance instanceof DataStoreInterface) {
$instance->setDateStore($sm->get('PDO\\Config'));
}
}, 'NotifyEventManagerAwareInterface' => function ($instance, $sm) {
if ($instance instanceof NotifyEventManagerAwareInterface) {
$instance->setEventManager($sm->get('ServiceEventManager'));
}
}, 'ServiceEventManagerAwareInterface' => function ($instance, $sm) {
if ($instance instanceof ServiceEventManagerAwareInterface) {
$instance->setEventManager($sm->get('ServiceEventManager'));
}
}), 'invokables' => ['Stjornvisi\\Service\\User' => 'Stjornvisi\\Service\\User', 'Stjornvisi\\Service\\Company' => 'Stjornvisi\\Service\\Company', 'Stjornvisi\\Service\\Event' => 'Stjornvisi\\Service\\Event', 'Stjornvisi\\Service\\Group' => 'Stjornvisi\\Service\\Group', 'Stjornvisi\\Service\\News' => 'Stjornvisi\\Service\\News', 'Stjornvisi\\Service\\Board' => 'Stjornvisi\\Service\\Board', 'Stjornvisi\\Service\\Article' => 'Stjornvisi\\Service\\Article', 'Stjornvisi\\Service\\Page' => 'Stjornvisi\\Service\\Page', 'Stjornvisi\\Service\\Values' => 'Stjornvisi\\Service\\Values', 'Stjornvisi\\Service\\Conference' => 'Stjornvisi\\Service\\Conference', 'Stjornvisi\\Service\\Skeleton' => 'Stjornvisi\\Service\\Skeleton', 'Stjornvisi\\Service\\Anaegjuvogin' => 'Stjornvisi\\Service\\Anaegjuvogin', 'Stjornvisi\\Notify\\Submission' => 'Stjornvisi\\Notify\\Submission', 'Stjornvisi\\Notify\\Event' => 'Stjornvisi\\Notify\\Event', 'Stjornvisi\\Notify\\Password' => 'Stjornvisi\\Notify\\Password', 'Stjornvisi\\Notify\\Group' => 'Stjornvisi\\Notify\\Group', 'Stjornvisi\\Notify\\All' => 'Stjornvisi\\Notify\\All', 'Stjornvisi\\Notify\\Attend' => 'Stjornvisi\\Notify\\Attend', 'Stjornvisi\\Notify\\UserValidate' => 'Stjornvisi\\Notify\\UserValidate', 'Stjornvisi\\Notify\\Digest' => 'Stjornvisi\\Notify\\Digest', 'Stjornvisi\\Event\\SystemExceptionListener' => 'Stjornvisi\\Event\\SystemExceptionListener', 'Stjornvisi\\Event\\PersistenceLoginListener' => 'Stjornvisi\\Event\\PersistenceLoginListener', 'Stjornvisi\\Event\\LayoutSelectListener' => 'Stjornvisi\\Event\\LayoutSelectListener', 'Stjornvisi\\Event\\NotifyListener' => 'Stjornvisi\\Event\\NotifyListener', 'Imagine\\Image\\Imagine' => 'Imagine\\Gd\\Imagine', 'Stjornvisi\\Auth\\Adapter' => 'Stjornvisi\\Auth\\Adapter', 'Stjornvisi\\Auth\\Facebook' => 'Stjornvisi\\Auth\\Facebook', 'AuthenticationService' => 'Zend\\Authentication\\AuthenticationService'], 'aliases' => array('UserService' => 'Stjornvisi\\Service\\User', 'GroupService' => 'Stjornvisi\\Service\\Group', 'Zend\\Authentication\\AuthenticationService' => 'AuthenticationService'), 'factories' => array('Logger' => function ($sm) {
$log = new Logger('stjornvisi');
$log->pushHandler(new StreamHandler('php://stdout'));
$evn = getenv('APPLICATION_ENV') ?: 'production';
if ($evn == 'development') {
//...
} else {
$handler = new StreamHandler('./data/log/error.json', Logger::ERROR);
$handler->setFormatter(new \Stjornvisi\Lib\JsonFormatter());
$log->pushHandler($handler);
$handler = new StreamHandler('./data/log/system.log');
$handler->setFormatter(new JsonFormatter());
$log->pushHandler($handler);
$log->pushHandler(new SlackHandler("xoxp-3745519896-3745519908-3921078470-26445a", "#stjornvisi", "Angry Hamster", true, null, Logger::CRITICAL));
}
return $log;
}, 'ServiceEventManager' => function ($sm) {
$logger = $sm->get('Logger');
$manager = new EventManager();
$manager->attach(new ErrorEventListener($logger));
$manager->attach(new ServiceEventListener($logger));
$activityListener = new ActivityListener($logger);
$activityListener->setQueueConnectionFactory($sm->get('Stjornvisi\\Lib\\QueueConnectionFactory'));
$manager->attach($activityListener);
return $manager;
}, 'Stjornvisi\\Service\\Map' => function ($sm) {
return new JaMap(new Client());
}, 'Stjornvisi\\Service\\Email' => function ($sm) {
$config = $sm->get('config');
$obj = new Email();
$obj->setDataSource(new PDO($config['tracker']['dns'], $config['tracker']['user'], $config['tracker']['password'], array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'", PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ)));
return $obj;
}, 'PDO\\Config' => function ($sm) {
$config = $sm->get('config');
return array('dns' => $config['db']['dns'], 'user' => $config['db']['user'], 'password' => $config['db']['password'], 'options' => array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'", PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ));
}, 'PDO' => function ($sm) {
$config = $sm->get('PDO\\Config');
return new PDO($config['dns'], $config['user'], $config['password'], $config['options']);
}, 'MailTransport' => function ($sm) {
$evn = getenv('APPLICATION_ENV') ?: 'production';
if ($evn == 'development') {
$transport = new FileTransport();
$transport->setOptions(new FileOptions(['path' => './data/', 'callback' => function (FileTransport $transport) {
return 'Message_' . microtime(true) . '.eml';
}]));
return $transport;
} else {
$transport = new SmtpTransport();
$protocol = new \Zend\Mail\Protocol\Smtp();
$transport->setConnection($protocol);
return $transport;
}
}, 'Stjornvisi\\Lib\\QueueConnectionFactory' => function ($sm) {
$evn = getenv('APPLICATION_ENV') ?: 'production';
if ($evn == 'testing') {
return new QueueConnectionFactoryStub();
}
$config = $sm->get('config');
$queue = new QueueConnectionFactory();
$queue->setConfig($config['queue']);
return $queue;
}, 'Stjornvisi\\Form\\NewUserCompanySelect' => function ($sm) {
return new NewUserCompanySelect($sm->get('Stjornvisi\\Service\\Company'));
}, 'Stjornvisi\\Form\\NewUserCompany' => function ($sm) {
return new NewUserCompany($sm->get('Stjornvisi\\Service\\Values'), $sm->get('Stjornvisi\\Service\\Company'));
}, 'Stjornvisi\\Form\\NewUserUniversitySelect' => function ($sm) {
return new NewUserUniversitySelect($sm->get('Stjornvisi\\Service\\Company'));
}, 'Stjornvisi\\Form\\NewUserIndividual' => function ($sm) {
//.........這裏部分代碼省略.........