Created
January 15, 2015 16:14
-
-
Save matej21/8634bba4a46c6b01607b to your computer and use it in GitHub Desktop.
Tovarna na message
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
- | |
implement: MessageFactory | |
setup: | |
- setFrom("[email protected]") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
interface MessageFactory | |
{ | |
/** | |
* @return \Nette\Mail\Message | |
*/ | |
public function create(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class FooService extends Nette\Object | |
{ | |
protected $messageFactory; | |
protected $mailer; | |
public function __construct(Nette\Mail\IMailer $mailer, MessageFactory $messageFactory) | |
{ | |
$this->messageFactory = $messageFactory; | |
$this->mailer = $mailer; | |
} | |
public function doSth() | |
{ | |
$message = $this->messageFactory->create(); | |
$message->setSubject(....); | |
$this->mailer->send($message); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment