From d9830a08451018bb5118a3d8217493c95ec9b7b3 Mon Sep 17 00:00:00 2001 From: Eric Wiese <eric.wiese@classyllama.com> Date: Wed, 24 Jun 2015 12:55:41 -0500 Subject: [PATCH] MAGETWO-37843: All responsive email templates in Blank Theme - Added support for (reference) directive to @magento_import --- .gitignore | 48 +------------------ .../Instruction/MagentoImport.php | 8 ++-- .../Instruction/MagentoImportTest.php | 21 ++++++++ .../Magento/Framework/Mail/Transport.php | 45 +---------------- 4 files changed, 28 insertions(+), 94 deletions(-) mode change 100644 => 120000 .gitignore mode change 100644 => 120000 lib/internal/Magento/Framework/Mail/Transport.php diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 406a5a58d34..00000000000 --- a/.gitignore +++ /dev/null @@ -1,47 +0,0 @@ -/.buildpath -/.cache -/.metadata -/.project -/.settings -atlassian* -/nbproject -/sitemap -/.idea -/.gitattributes -/app/config_sandbox -/app/etc/config.php -/app/etc/env.php -/app/code/Magento/TestModule* -/lib/internal/flex/uploader/.actionScriptProperties -/lib/internal/flex/uploader/.flexProperties -/lib/internal/flex/uploader/.project -/lib/internal/flex/uploader/.settings -/lib/internal/flex/varien/.actionScriptProperties -/lib/internal/flex/varien/.flexLibProperties -/lib/internal/flex/varien/.project -/lib/internal/flex/varien/.settings -/node_modules -/.grunt - -/pub/media/*.* -!/pub/media/.htaccess -/pub/media/catalog/* -!/pub/media/catalog/.htaccess -/pub/media/customer/* -!/pub/media/customer/.htaccess -/pub/media/downloadable/* -!/pub/media/downloadable/.htaccess -/pub/media/theme/* -/pub/media/theme_customization/* -!/pub/media/theme_customization/.htaccess -/pub/media/wysiwyg/* -!/pub/media/wysiwyg/.htaccess -/pub/media/tmp/* -!/pub/media/tmp/.htaccess -/pub/media/captcha/* -/pub/static/* -!/pub/static/.htaccess - -/var/* -!/var/.htaccess -/vendor diff --git a/.gitignore b/.gitignore new file mode 120000 index 00000000000..c42dfc56a36 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.modman/magento2-responsive-email-test-data/.gitignore \ No newline at end of file diff --git a/lib/internal/Magento/Framework/Less/PreProcessor/Instruction/MagentoImport.php b/lib/internal/Magento/Framework/Less/PreProcessor/Instruction/MagentoImport.php index 26d95fb2c26..45094e9618a 100644 --- a/lib/internal/Magento/Framework/Less/PreProcessor/Instruction/MagentoImport.php +++ b/lib/internal/Magento/Framework/Less/PreProcessor/Instruction/MagentoImport.php @@ -20,7 +20,7 @@ class MagentoImport implements PreProcessorInterface /** * PCRE pattern that matches @magento_import LESS instruction */ - const REPLACE_PATTERN = '#//@magento_import\s+[\'\"](?P<path>(?![/\\\]|\w:[/\\\])[^\"\']+)[\'\"]\s*?;#'; + const REPLACE_PATTERN = '#//@magento_import(?P<reference>\s+\(reference\))?\s+[\'\"](?P<path>(?![/\\\]|\w:[/\\\])[^\"\']+)[\'\"]\s*?;#'; /** * @var DesignInterface @@ -92,14 +92,16 @@ class MagentoImport implements PreProcessorInterface $importsContent = ''; try { $matchedFileId = $matchedContent['path']; + $isReference = !empty($matchedContent['reference']); $relatedAsset = $this->assetRepo->createRelated($matchedFileId, $asset); $resolvedPath = $relatedAsset->getFilePath(); $importFiles = $this->fileSource->getFiles($this->getTheme($relatedAsset), $resolvedPath); /** @var $importFile \Magento\Framework\View\File */ foreach ($importFiles as $importFile) { + $referenceString = $isReference ? '(reference) ' : ''; $importsContent .= $importFile->getModule() - ? "@import '{$importFile->getModule()}::{$resolvedPath}';\n" - : "@import '{$matchedFileId}';\n"; + ? "@import $referenceString'{$importFile->getModule()}::{$resolvedPath}';\n" + : "@import $referenceString'{$matchedFileId}';\n"; } } catch (\LogicException $e) { $this->errorHandler->processException($e); diff --git a/lib/internal/Magento/Framework/Less/Test/Unit/PreProcessor/Instruction/MagentoImportTest.php b/lib/internal/Magento/Framework/Less/Test/Unit/PreProcessor/Instruction/MagentoImportTest.php index f4b0be5f57e..e8837987d14 100644 --- a/lib/internal/Magento/Framework/Less/Test/Unit/PreProcessor/Instruction/MagentoImportTest.php +++ b/lib/internal/Magento/Framework/Less/Test/Unit/PreProcessor/Instruction/MagentoImportTest.php @@ -135,6 +135,27 @@ class MagentoImportTest extends \PHPUnit_Framework_TestCase ], "@import 'Magento_Module::some/file.css';\n@import 'Magento_Two::some/file.css';\n", ], + 'non-modular reference notation' => [ + '//@magento_import (reference) "some/file.css";', + 'some/file.css', + 'some/file.css', + [ + ['module' => null, 'filename' => 'some/file.css'], + ['module' => null, 'filename' => 'theme/some/file.css'], + ], + "@import (reference) 'some/file.css';\n@import (reference) 'some/file.css';\n", + ], + 'modular reference' => [ + '//@magento_import (reference) "Magento_Module::some/file.css";', + 'Magento_Module::some/file.css', + 'some/file.css', + [ + ['module' => 'Magento_Module', 'filename' => 'some/file.css'], + ['module' => 'Magento_Two', 'filename' => 'some/file.css'], + ], + "@import (reference) 'Magento_Module::some/file.css';\n" . + "@import (reference) 'Magento_Two::some/file.css';\n", + ], ]; } diff --git a/lib/internal/Magento/Framework/Mail/Transport.php b/lib/internal/Magento/Framework/Mail/Transport.php deleted file mode 100644 index 89efe6b006e..00000000000 --- a/lib/internal/Magento/Framework/Mail/Transport.php +++ /dev/null @@ -1,44 +0,0 @@ -<?php -/** - * Mail Transport - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Framework\Mail; - -class Transport extends \Zend_Mail_Transport_Sendmail implements \Magento\Framework\Mail\TransportInterface -{ - /** - * @var \Magento\Framework\Mail\MessageInterface - */ - protected $_message; - - /** - * @param MessageInterface $message - * @param null $parameters - * @throws \InvalidArgumentException - */ - public function __construct(\Magento\Framework\Mail\MessageInterface $message, $parameters = null) - { - if (!$message instanceof \Zend_Mail) { - throw new \InvalidArgumentException('The message should be an instance of \Zend_Mail'); - } - parent::__construct($parameters); - $this->_message = $message; - } - - /** - * Send a mail using this transport - * - * @return void - * @throws \Magento\Framework\Exception\MailException - */ - public function sendMessage() - { - try { - parent::send($this->_message); - } catch (\Exception $e) { - throw new \Magento\Framework\Exception\MailException(new \Magento\Framework\Phrase($e->getMessage()), $e); - } - } -} diff --git a/lib/internal/Magento/Framework/Mail/Transport.php b/lib/internal/Magento/Framework/Mail/Transport.php new file mode 120000 index 00000000000..d1a9c0fe691 --- /dev/null +++ b/lib/internal/Magento/Framework/Mail/Transport.php @@ -0,0 +1 @@ +../../../../../.modman/magento2-responsive-email-test-data/lib/internal/Magento/Framework/Mail/Transport.php \ No newline at end of file -- GitLab