* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\PrestaShop\Core\MailTemplate\Transformation; use Html2Text\Html2Text; use PrestaShop\PrestaShop\Core\MailTemplate\MailTemplateInterface; /** * HTMLTextifyTransformation is used to remove any HTML tags from the template. It * is especially useful when no txt layout is defined and the renderer uses the html * layout as a base. This transformation then removes any html tags but keep the raw * information. */ class HTMLToTextTransformation extends AbstractTransformation { public function __construct() { parent::__construct(MailTemplateInterface::TXT_TYPE); } /** * {@inheritdoc} */ public function apply($templateContent, array $templateVariables) { $templateContent = Html2Text::convert($templateContent, true); if (PHP_EOL != $templateContent[strlen($templateContent) - 1]) { $templateContent .= PHP_EOL; } return $templateContent; } }