ConvertHeadersStylesPlugin::Init()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
class ConvertHeadersStylesPlugin extends \RainLoop\Plugins\AbstractPlugin
4
{
5
	public function Init()
6
	{
7
		$this->addHook('filter.result-message', 'FilterResultMessage');
8
	}
9
10
	/**
11
	 * @param \MailSo\Mail\Message &$oMessage
12
	 */
13
	public function FilterResultMessage(&$oMessage)
14
	{
15
		if ($oMessage)
16
		{
17
			$sHtml = $oMessage->Html();
18
			if ($sHtml && 0 < strlen($sHtml))
19
			{
20
				include_once __DIR__.'/CssToInlineStyles.php';
21
				
22
				$oCSSToInlineStyles = new \TijsVerkoyen\CssToInlineStyles\CssToInlineStyles($sHtml);
23
				$oCSSToInlineStyles->setEncoding('utf-8');
24
				$oCSSToInlineStyles->setUseInlineStylesBlock(true);
25
				$oMessage->SetHtml($oCSSToInlineStyles->convert().'<!-- convert-headers-styles-plugin -->');
26
			}
27
		}
28
	}
29
}
30