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
...@@ -4,13 +4,22 @@ namespace WPDesk\Library\WPEmail\Abstracts; ...@@ -4,13 +4,22 @@ namespace WPDesk\Library\WPEmail\Abstracts;
use WPDesk\View\Renderer\Renderer; use WPDesk\View\Renderer\Renderer;
abstract class EmailAbstract implements EmailInterface { abstract class EmailGettersAbstract implements EmailGettersInterface, EmailSettersInterface {
/** /**
* @var Renderer * @var Renderer
*/ */
private $renderer; private $renderer;
/**
* @var string
*/
private $subject;
/**
* @var string
*/
private $heading;
public function __construct( Renderer $renderer, array $recipients ) { public function __construct( Renderer $renderer, array $recipients ) {
$this->renderer = $renderer; $this->renderer = $renderer;
$this->recipients = $recipients; $this->recipients = $recipients;
...@@ -45,6 +54,13 @@ abstract class EmailAbstract implements EmailInterface { ...@@ -45,6 +54,13 @@ abstract class EmailAbstract implements EmailInterface {
return ''; return '';
} }
public function set_subject( string $subject ): self {
$this->subject = $subject;
return $this;
}
/** /**
* Get email heading. * Get email heading.
* *
...@@ -54,6 +70,13 @@ abstract class EmailAbstract implements EmailInterface { ...@@ -54,6 +70,13 @@ abstract class EmailAbstract implements EmailInterface {
return ''; return '';
} }
public function set_heading( string $heading ): self {
$this->heading = $heading;
return $this;
}
/** /**
* Get valid recipients. * Get valid recipients.
* *
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
namespace WPDesk\Library\WPEmail\Abstracts; namespace WPDesk\Library\WPEmail\Abstracts;
interface EmailInterface { interface EmailGettersInterface {
/** /**
* Define unique email ID. * Define unique email ID.
......
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
namespace WPDesk\Library\WPEmail\Emails; namespace WPDesk\Library\WPEmail\Emails;
use WPDesk\Library\WPEmail\Abstracts\EmailInterface; use WPDesk\Library\WPEmail\Abstracts\EmailGettersInterface;
class EmailSender { class EmailSender {
/** /**
* @var EmailInterface[] * @var EmailGettersInterface[]
*/ */
private $emails = []; private $emails = [];
...@@ -30,7 +30,7 @@ class EmailSender { ...@@ -30,7 +30,7 @@ class EmailSender {
$this->from_name = $from_name; $this->from_name = $from_name;
} }
public function add_email( EmailInterface $email ) { public function add_email( Email $email ) {
$this->emails[ $email->get_id() ] = $email; $this->emails[ $email->get_id() ] = $email;
} }
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
namespace WPDesk\Library\WPEmail\Emails; 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'; const ID = 'email';
......
...@@ -22,6 +22,7 @@ class Integration { ...@@ -22,6 +22,7 @@ class Integration {
$email_sender = new EmailSender( 'email@mojastron.pl', 'Moj sklep' ); $email_sender = new EmailSender( 'email@mojastron.pl', 'Moj sklep' );
$email = new Email( $renderer, [] ); $email = new Email( $renderer, [] );
$email->set_subject( 'Tytuł')->set_heading( 'Nowa wiadomość' );
$email_sender->add_email( $email ); $email_sender->add_email( $email );
$email_sender->send(); $email_sender->send();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment