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

init

parent 1df74b3a
No related branches found
No related tags found
1 merge request!2Devel
Pipeline #150354 passed
This commit is part of merge request !2. Comments created here will be created in the context of that merge request.
<?php
namespace WPDesk\Library\WPEmail\Abstracts;
use WPDesk\View\Renderer\Renderer;
interface ConditionInterface {
public function is_valid(): bool;
}
......@@ -4,7 +4,7 @@ namespace WPDesk\Library\WPEmail\Abstracts;
use WPDesk\View\Renderer\Renderer;
abstract class EmailGettersAbstract implements EmailGettersInterface, EmailSettersInterface {
abstract class EmailGettersAbstract implements EmailGettersInterface, ConditionInterface {
/**
* @var Renderer
......@@ -142,4 +142,8 @@ abstract class EmailGettersAbstract implements EmailGettersInterface, EmailSette
return $this->renderer->render( dirname( __DIR__ ) . '/html/default.php', [ 'content' => $this->get_content(), 'heading' => $this->get_heading(), 'object' => $this->get_object() ] );
}
public function is_valid(): bool {
return true;
}
}
......@@ -2,6 +2,7 @@
namespace WPDesk\Library\WPEmail\Emails;
use WPDesk\Library\WPEmail\Abstracts\ConditionInterface;
use WPDesk\Library\WPEmail\Abstracts\EmailGettersInterface;
class EmailSender {
......@@ -81,9 +82,15 @@ class EmailSender {
public function send() {
foreach ( $this->get_emails() as $email ) {
$this->before_wp_mail();
if( $email instanceof ConditionInterface ) {
if( $email->is_valid() ) {
wp_mail(
$email->get_recipients(), $email->get_subject(), $email->render(), $email->get_headers(), $email->get_attachments()
);
}
}
$this->after_wp_mail();
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment