Skip to content
Snippets Groups Projects
Commit 1df74b3a authored by Piotr Potrebka's avatar Piotr Potrebka
Browse files

init

parent 53209129
No related branches found
No related tags found
1 merge request!2Devel
Pipeline #150353 passed
This commit is part of merge request !2. Comments created here will be created in the context of that merge request.
......@@ -4,13 +4,22 @@ namespace WPDesk\Library\WPEmail\Abstracts;
use WPDesk\View\Renderer\Renderer;
abstract class EmailAbstract implements EmailInterface {
abstract class EmailGettersAbstract implements EmailGettersInterface, EmailSettersInterface {
/**
* @var Renderer
*/
private $renderer;
/**
* @var string
*/
private $subject;
/**
* @var string
*/
private $heading;
public function __construct( Renderer $renderer, array $recipients ) {
$this->renderer = $renderer;
$this->recipients = $recipients;
......@@ -45,6 +54,13 @@ abstract class EmailAbstract implements EmailInterface {
return '';
}
public function set_subject( string $subject ): self {
$this->subject = $subject;
return $this;
}
/**
* Get email heading.
*
......@@ -54,6 +70,13 @@ abstract class EmailAbstract implements EmailInterface {
return '';
}
public function set_heading( string $heading ): self {
$this->heading = $heading;
return $this;
}
/**
* Get valid recipients.
*
......
......@@ -2,7 +2,7 @@
namespace WPDesk\Library\WPEmail\Abstracts;
interface EmailInterface {
interface EmailGettersInterface {
/**
* Define unique email ID.
......
......@@ -2,12 +2,12 @@
namespace WPDesk\Library\WPEmail\Emails;
use WPDesk\Library\WPEmail\Abstracts\EmailInterface;
use WPDesk\Library\WPEmail\Abstracts\EmailGettersInterface;
class EmailSender {
/**
* @var EmailInterface[]
* @var EmailGettersInterface[]
*/
private $emails = [];
......@@ -30,7 +30,7 @@ class EmailSender {
$this->from_name = $from_name;
}
public function add_email( EmailInterface $email ) {
public function add_email( Email $email ) {
$this->emails[ $email->get_id() ] = $email;
}
......
......@@ -2,9 +2,9 @@
namespace WPDesk\Library\WPEmail\Emails;
use WPDesk\Library\WPEmail\Abstracts\EmailAbstract;
use WPDesk\Library\WPEmail\Abstracts\EmailGettersAbstract;
class Email extends EmailAbstract {
class Email extends EmailGettersAbstract {
const ID = 'email';
......
......@@ -22,6 +22,7 @@ class Integration {
$email_sender = new EmailSender( 'email@mojastron.pl', 'Moj sklep' );
$email = new Email( $renderer, [] );
$email->set_subject( 'Tytuł')->set_heading( 'Nowa wiadomość' );
$email_sender->add_email( $email );
$email_sender->send();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment