Refactor Form\Utils\Styles to injectable service

[MAILPOET-2451]
This commit is contained in:
Rostislav Wolny
2019-12-02 17:31:58 +01:00
committed by Jack Kitterhing
parent d25de883e7
commit effd37a0ad
5 changed files with 21 additions and 15 deletions

View File

@@ -6,7 +6,7 @@ use MailPoetVendor\Sabberworm\CSS\Parser as CSSParser;
class Styles {
public $styles;
static $default_styles = <<<EOL
private $default_styles = <<<EOL
/* form */
.mailpoet_form {
@@ -79,15 +79,14 @@ class Styles {
background-color: #5b5b5b;
}
EOL;
private $stylesheet;
function __construct($stylesheet = null) {
$this->stylesheet = $stylesheet;
function getDefaultStyles() {
return $this->default_styles;
}
function render($prefix = '') {
if (!$this->stylesheet) return;
$styles = new CSSParser($this->stylesheet);
function render($stylesheet, $prefix = '') {
if (!$stylesheet) return;
$styles = new CSSParser($stylesheet);
$styles = $styles->parse();
$formatted_styles = [];
foreach ($styles->getAllDeclarationBlocks() as $style_declaration) {