Skip to content

Instantly share code, notes, and snippets.

@matej21
Created January 15, 2015 16:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save matej21/8634bba4a46c6b01607b to your computer and use it in GitHub Desktop.
Save matej21/8634bba4a46c6b01607b to your computer and use it in GitHub Desktop.
Tovarna na message
services:
-
implement: MessageFactory
setup:
- setFrom("foo@bar.com")
<?php
interface MessageFactory
{
/**
* @return \Nette\Mail\Message
*/
public function create();
}
<?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