Implement MailPoet version of CSS Inliner
[MAILPOET-6428]
This commit is contained in:
committed by
Oluwaseun Olorunsola
parent
ddf6570f50
commit
02fc9b2618
@@ -360,6 +360,10 @@ class ContainerConfigurator implements IContainerConfigurator {
|
||||
$container->autowire(\MailPoet\EmailEditor\Integrations\MailPoet\Cli::class)->setPublic(true);
|
||||
$container->autowire(\MailPoet\EmailEditor\Integrations\MailPoet\EmailEditor::class)->setPublic(true);
|
||||
$container->autowire(\MailPoet\EmailEditor\Integrations\MailPoet\EditorPageRenderer::class)->setPublic(true);
|
||||
$container->register(\MailPoet\EmailEditor\Engine\Renderer\Css_Inliner::class)
|
||||
->setPublic(true)
|
||||
->setFactory([\MailPoet\EmailEditor\Integrations\MailPoet\MailpoetCssInlinerFactory::class, 'create']);
|
||||
$container->autowire(\MailPoet\EmailEditor\Integrations\MailPoet\MailPoetCssInliner::class)->setPublic(true);
|
||||
$container->autowire(\MailPoet\EmailEditor\Integrations\MailPoet\EmailApiController::class)->setPublic(true);
|
||||
$container->autowire(\MailPoet\EmailEditor\Integrations\MailPoet\EmailEditorPreviewEmail::class)->setPublic(true);
|
||||
$container->autowire(\MailPoet\EmailEditor\Integrations\MailPoet\DependencyNotice::class)->setPublic(true);
|
||||
|
@@ -0,0 +1,25 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace MailPoet\EmailEditor\Integrations\MailPoet;
|
||||
|
||||
use MailPoet\EmailEditor\Engine\Renderer\Css_Inliner;
|
||||
use MailPoetVendor\Pelago\Emogrifier\CssInliner;
|
||||
|
||||
class MailPoetCssInliner implements Css_Inliner {
|
||||
private CssInliner $inliner;
|
||||
|
||||
public function from_html(string $unprocessed_html): self {// phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
|
||||
$that = new self();
|
||||
$that->inliner = CssInliner::fromHtml($unprocessed_html);
|
||||
return $that;
|
||||
}
|
||||
|
||||
public function inline_css(string $css = ''): self {// phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
|
||||
$this->inliner->inlineCss($css);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render(): string {
|
||||
return $this->inliner->render();
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace MailPoet\EmailEditor\Integrations\MailPoet;
|
||||
|
||||
class MailpoetCssInlinerFactory {
|
||||
public static function create(): MailPoetCssInliner {
|
||||
return new MailPoetCssInliner();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user