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

init

parent 0dab44d4
No related branches found
No related tags found
1 merge request!1Devel
Pipeline #150342 passed
......@@ -11,8 +11,9 @@ abstract class EmailAbstract implements EmailInterface {
*/
private $renderer;
public function __construct( Renderer $renderer ) {
public function __construct( Renderer $renderer, array $recipients ) {
$this->renderer = $renderer;
$this->recipients = $recipients;
}
/**
......@@ -37,6 +38,10 @@ abstract class EmailAbstract implements EmailInterface {
* @return string
*/
public function get_subject(): string {
if ( ! $this->subject ) {
throw new \Exception( 'Empty email subject' );
}
return '';
}
......@@ -55,7 +60,7 @@ abstract class EmailAbstract implements EmailInterface {
* @return string[]
*/
public function get_recipients(): array {
return [];
return $this->recipients;
}
/**
......@@ -91,6 +96,10 @@ abstract class EmailAbstract implements EmailInterface {
* @return string
*/
public function get_content(): string {
if ( ! $this->content ) {
throw new \Exception( 'Empty email subject' );
}
return '';
}
......
......@@ -67,11 +67,4 @@ interface EmailInterface {
*/
public function get_content(): string;
/**
* Send email.
*
* @return void
*/
public function send(): void;
}
<?php
namespace WPDesk\Library\WPEmail;
use WPDesk\Library\WPEmail\Emails\AdminEmail;
use WPDesk\Library\WPEmail\Emails\Email;
use WPDesk\Library\WPEmail\Emails\EmailSender;
use WPDesk\Persistence\Adapter\WordPress\WordpressOptionsContainer;
use WPDesk\Persistence\Adapter\WordPress\WordpressTransientContainer;
use WPDesk\View\Renderer\SimplePhpRenderer;
use WPDesk\View\Resolver\ChainResolver;
use WPDesk\View\Resolver\DirResolver;
use WPDesk\View\Resolver\WPThemeResolver;
class Integration {
public function __construct() {
$chain_resolver = new ChainResolver();
$chain_resolver->appendResolver( new WPThemeResolver( 'email_templates' ) );
$chain_resolver->appendResolver( new DirResolver( __DIR__ . '/templates' ) );
$renderer = new SimplePhpRenderer( $chain_resolver );
$email_sender = new EmailSender( 'email@mojastron.pl', 'Moj sklep' );
$email = new Email( $renderer, [] );
$email_sender->add_email( $email );
$email_sender->send();
}
}
<?php
namespace WPDesk\Library\WPEmail\Parser;
class HTMLDecorator {
public static function style_inline( $content ) {
if ( in_array( $this->get_content_type(), array( 'text/html', 'multipart/alternative' ), true ) ) {
ob_start();
wc_get_template( 'emails/email-styles.php' );
$css = apply_filters( 'woocommerce_email_styles', ob_get_clean(), $this );
$css_inliner_class = \Pelago\Emogrifier\CssInliner::class;
if ( $this->supports_emogrifier() && class_exists( $css_inliner_class ) ) {
try {
$css_inliner = \Pelago\Emogrifier\CssInliner::fromHtml( $content )->inlineCss( $css );
do_action( 'woocommerce_emogrifier', $css_inliner, $this );
$dom_document = $css_inliner->getDomDocument();
HtmlPruner::fromDomDocument( $dom_document )->removeElementsWithDisplayNone();
$content = CssToAttributeConverter::fromDomDocument( $dom_document )
->convertCssToVisualAttributes()
->render();
} catch ( Exception $e ) {
$logger = wc_get_logger();
$logger->error( $e->getMessage(), array( 'source' => 'emogrifier' ) );
}
} else {
$content = '<style type="text/css">' . $css . '</style>' . $content;
}
}
return $content;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment