浏览代码

Try to use composer dependency.

Mark Scherer 10 年之前
父节点
当前提交
c860f80dba
共有 3 个文件被更改,包括 10 次插入5 次删除
  1. 6 4
      Lib/InlineCssLib.php
  2. 1 1
      Test/Case/Lib/InlineCssLibTest.php
  3. 3 0
      composer.json

+ 6 - 4
Lib/InlineCssLib.php

@@ -63,10 +63,12 @@ class InlineCssLib {
 	 * @return string Result
 	 */
 	protected function _processEmogrifier($html, $css) {
-		//$css .= $this->_extractAndRemoveCss($html);
-		App::import('Vendor', 'Tools.Emogrifier', ['file' => 'Emogrifier/Emogrifier.php']);
-
-		$Emogrifier = new Emogrifier($html, $css);
+		if (class_exists('\Pelago\Emogrifier')) {
+			$Emogrifier = new \Pelago\Emogrifier($html, $css);
+		} else {
+			App::import('Vendor', 'Tools.Emogrifier', ['file' => 'Emogrifier/Emogrifier.php']);
+			$Emogrifier = new Emogrifier($html, $css);
+		}
 		//$Emogrifier->preserveEncoding = true;
 
 		$result = $Emogrifier->emogrify();

+ 1 - 1
Test/Case/Lib/InlineCssLibTest.php

@@ -218,7 +218,7 @@ bla';
 		$html = file_get_contents($path . 'email_template.html');
 		$result = $this->InlineCss->process($html);
 		$this->debug($result);
-		$expected = '<td  style="vertical-align:top;';
+		$expected = '<td  style="vertical-align:';
 		$this->assertTextContains($expected, $result);
 
 		$this->InlineCss = new InlineCssLib(['engine' => InlineCssLib::ENGINE_EMOGRIFIER]);

+ 3 - 0
composer.json

@@ -22,5 +22,8 @@
 	},
 	"extra": {
 		"installer-name": "Tools"
+	},
+	"suggest": {
+		"pelago/emogrifier": "When using InlineCss lib and CSS to inline HTML transformation."
 	}
 }