Browse Source

simplenews symfony template

bach 2 years ago
parent
commit
ef6222c130

+ 0 - 1
composer.json

@@ -156,7 +156,6 @@
         "drupal/string_translation_ui": "^1.2",
         "drupal/strings_i18n_json_export": "^1.x-dev@dev",
         "drupal/structure_sync": "^2.0",
-        "drupal/swiftmailer": "^2.x-dev@dev",
         "drupal/symfony_mailer": "^1.0@alpha",
         "drupal/synonyms": "^2.0.0-beta2",
         "drupal/telephone_formatter": "^1.0@beta",

+ 1 - 145
composer.lock

@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "78f26bb64269c36ef8750454f9b8fbea",
+    "content-hash": "37949e67c842c709dfa915af08bb2925",
     "packages": [
         {
             "name": "alchemy/zippy",
@@ -13609,73 +13609,6 @@
                 "source": "https://git.drupalcode.org/project/structure_sync"
             }
         },
-        {
-            "name": "drupal/swiftmailer",
-            "version": "dev-2.x",
-            "source": {
-                "type": "git",
-                "url": "https://git.drupalcode.org/project/swiftmailer.git",
-                "reference": "8dd88509d6da0adba532269aae0caad929f6a574"
-            },
-            "require": {
-                "drupal/core": "^8.9.11 || ^9.0.10",
-                "drupal/mailsystem": "^4.1.0",
-                "egulias/email-validator": "^2.0||^3",
-                "html2text/html2text": "^4.0.1",
-                "php": ">=7.0.0",
-                "swiftmailer/swiftmailer": "^6.1.3",
-                "tijsverkoyen/css-to-inline-styles": "^2.2"
-            },
-            "type": "drupal-module",
-            "extra": {
-                "branch-alias": {
-                    "dev-2.x": "2.x-dev"
-                },
-                "drupal": {
-                    "version": "8.x-2.1+1-dev",
-                    "datestamp": "1639067975",
-                    "security-coverage": {
-                        "status": "not-covered",
-                        "message": "Dev releases are not covered by Drupal security advisories."
-                    }
-                }
-            },
-            "notification-url": "https://packages.drupal.org/8/downloads",
-            "license": [
-                "GPL-2.0-or-later"
-            ],
-            "authors": [
-                {
-                    "name": "AdamPS",
-                    "homepage": "https://www.drupal.org/user/2650563"
-                },
-                {
-                    "name": "Anybody",
-                    "homepage": "https://www.drupal.org/user/291091"
-                },
-                {
-                    "name": "B-Prod",
-                    "homepage": "https://www.drupal.org/user/407852"
-                },
-                {
-                    "name": "geek-merlin",
-                    "homepage": "https://www.drupal.org/user/229048"
-                },
-                {
-                    "name": "sbrattla",
-                    "homepage": "https://www.drupal.org/user/53422"
-                },
-                {
-                    "name": "webflo",
-                    "homepage": "https://www.drupal.org/user/254778"
-                }
-            ],
-            "description": "Swiftmailer",
-            "homepage": "https://www.drupal.org/project/swiftmailer",
-            "support": {
-                "source": "https://git.drupalcode.org/project/swiftmailer"
-            }
-        },
         {
             "name": "drupal/symfony_mailer",
             "version": "1.0.0-alpha9",
@@ -19476,82 +19409,6 @@
                 "installer-name": "svg-pan-zoom"
             }
         },
-        {
-            "name": "swiftmailer/swiftmailer",
-            "version": "v6.3.0",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/swiftmailer/swiftmailer.git",
-                "reference": "8a5d5072dca8f48460fce2f4131fcc495eec654c"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/8a5d5072dca8f48460fce2f4131fcc495eec654c",
-                "reference": "8a5d5072dca8f48460fce2f4131fcc495eec654c",
-                "shasum": ""
-            },
-            "require": {
-                "egulias/email-validator": "^2.0|^3.1",
-                "php": ">=7.0.0",
-                "symfony/polyfill-iconv": "^1.0",
-                "symfony/polyfill-intl-idn": "^1.10",
-                "symfony/polyfill-mbstring": "^1.0"
-            },
-            "require-dev": {
-                "mockery/mockery": "^1.0",
-                "symfony/phpunit-bridge": "^4.4|^5.4"
-            },
-            "suggest": {
-                "ext-intl": "Needed to support internationalized email addresses"
-            },
-            "type": "library",
-            "extra": {
-                "branch-alias": {
-                    "dev-master": "6.2-dev"
-                }
-            },
-            "autoload": {
-                "files": [
-                    "lib/swift_required.php"
-                ]
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "MIT"
-            ],
-            "authors": [
-                {
-                    "name": "Chris Corbyn"
-                },
-                {
-                    "name": "Fabien Potencier",
-                    "email": "fabien@symfony.com"
-                }
-            ],
-            "description": "Swiftmailer, free feature-rich PHP mailer",
-            "homepage": "https://swiftmailer.symfony.com",
-            "keywords": [
-                "email",
-                "mail",
-                "mailer"
-            ],
-            "support": {
-                "issues": "https://github.com/swiftmailer/swiftmailer/issues",
-                "source": "https://github.com/swiftmailer/swiftmailer/tree/v6.3.0"
-            },
-            "funding": [
-                {
-                    "url": "https://github.com/fabpot",
-                    "type": "github"
-                },
-                {
-                    "url": "https://tidelift.com/funding/github/packagist/swiftmailer/swiftmailer",
-                    "type": "tidelift"
-                }
-            ],
-            "abandoned": "symfony/mailer",
-            "time": "2021-10-18T15:26:12+00:00"
-        },
         {
             "name": "symfony-cmf/routing",
             "version": "2.3.4",
@@ -25715,7 +25572,6 @@
         "drupal/session_limit": 10,
         "drupal/simplenews": 20,
         "drupal/strings_i18n_json_export": 20,
-        "drupal/swiftmailer": 20,
         "drupal/symfony_mailer": 15,
         "drupal/telephone_formatter": 10,
         "drupal/translate_side_by_side": 20,

+ 8 - 5
config/sync/symfony_mailer.mailer_policy.simplenews.subscribe.yml

@@ -8,11 +8,14 @@ _core:
   default_config_hash: eS_mn5V1pRFDUx66hVOesANK1KjPtyMQBr8v0JEBp-A
 id: simplenews.subscribe
 configuration:
-  email_subject:
-    value: 'Confirmation for [site:name]'
+  email_from:
+    addresses:
+      -
+        value: news@materio.com
+        display: ''
   email_body:
     content:
-      value: |-
-        <p>We have received a request to subscribe [simplenews-subscriber:mail] at <a href="[site:url]">[site:name]</a>.
-        Please use this link to <a href="[simplenews-subscriber:combined-url]">confirm your subscribtion</a>.</p>
+      value: "<p>We have received a request to subscribe [simplenews-subscriber:mail] at <a href=\"[site:url]\">[site:name]</a>.\r\nPlease use this link to <a href=\"[simplenews-subscriber:combined-url]\">confirm your subscribtion</a>.</p>"
       format: email_html
+  email_subject:
+    value: 'Confirmation for [site:name]'

+ 8 - 5
config/sync/symfony_mailer.mailer_policy.simplenews.validate.yml

@@ -8,11 +8,14 @@ _core:
   default_config_hash: 5Oh2xuv7tqN5i5bnfKD00U_BBPkar6m2je0uO0SQNc4
 id: simplenews.validate
 configuration:
-  email_subject:
-    value: 'Manage your subscriptions at [site:name]'
+  email_from:
+    addresses:
+      -
+        value: news@materio.com
+        display: ''
   email_body:
     content:
-      value: |-
-        <p>We have received a request to manage your subscriptions for [simplenews-subscriber:mail] at <a href="[site:url]">[site:name]</a>.
-        Please use this link to <a href="[simplenews-subscriber:manage-url]">proceed</a>.</p>
+      value: "<p>We have received a request to manage your subscriptions for [simplenews-subscriber:mail] at <a href=\"[site:url]\">[site:name]</a>.\r\nPlease use this link to <a href=\"[simplenews-subscriber:manage-url]\">proceed</a>.</p>"
       format: email_html
+  email_subject:
+    value: 'Manage your subscriptions at [site:name]'

+ 0 - 4
config/sync/symfony_mailer.mailer_policy.simplenews_newsletter.yml

@@ -13,9 +13,5 @@ configuration:
       -
         value: news@materio.com
         display: ''
-  email_body:
-    content:
-      value: "<div class=\"clearfix\">\r\n  {{ body }}\r\n</div>\r\n\r\n{% if not opt_out_hidden %}\r\n  <p class=\"simplenews-unsubscribe\"><a href=\"[simplenews-subscriber:unsubscribe-url]\">Unsubscribe from this newsletter</a></p>\r\n{% endif %}\r\n\r\n{% if test %}\r\n  <p class=\"simplenews-test-message\">This is a test version of the newsletter.</p>\r\n{% endif %}"
-      format: email_html
   email_subject:
     value: '[node:title]'

+ 143 - 0
web/themes/custom/materiotheme/templates/email-simplenews-newsletter.html.twig

@@ -0,0 +1,143 @@
+{#
+/**
+ * @file
+ * Default theme implementation to format the simplenews newsletter body.
+ *
+ * Copy this file in your theme directory to create a custom themed body.
+ * Rename it to override it. Available templates:
+ *   simplenews-newsletter-body--[newsletter_id].html.twig
+ *   simplenews-newsletter-body--[view mode].html.twig
+ *   simplenews-newsletter-body--[newsletter_id]--[view mode].html.twig
+ * See README.txt for more details.
+ *
+ * Available variables:
+ * - build: Render array. Use {{ build }} to print it.
+ * - node: object(Drupal\node\Entity\Node)
+ *   The node entity with limited access to object properties and methods.
+ *   * Methods: Only "getter" methods (method names starting with "get", "has", or "is")
+ *     and a few common methods such as "id" and "label" are available.
+ *     {{ node.getTitle }} : the Node title ( == {{ title }} )
+ *     Calling other methods (such as node.delete) will result in an exception.
+ *   * Properties: field values can be accessed as follows:
+ *     {{ node.body.value | raw }} : text of body field
+ * - newsletter: object(Drupal\simplenews\Entity\Newsletter)
+ *     {{ newsletter.from_name }}: string
+ *     {{ newsletter.subject }}: string
+ * - title: Node title
+ * - view_mode: The active display view mode of the node
+ * - key: email key [node|test]
+ * - format: newsletter format [plain|html]
+ * - simplenews_subscriber: object(Drupal\simplenews\Entity\Subscriber)
+ *   The subscriber for which the newsletter is built.
+ *     {{ simplenews_subscriber.getMail  }}: string: subscriber's email address
+ *   Note that depending on the used caching strategy, the generated body might
+ *   be used for multiple subscribers. If you created personalized newsletters
+ *   and can't use tokens for that, make sure to disable caching or write a
+ *   custom caching strategy implemention.
+ *
+ * @see template_preprocess_simplenews_newsletter_body()
+ */
+#}
+
+<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
+  <tbody>
+    <tr>
+      <td style="padding: 37px 0; background-color: #eeeeee; text-align:center;" align="center" bgcolor="#eeeeee">
+        <!-- #nl_container -->
+        <p style="text-align:center; margin:5px 0;"><a href="{{ path('entity.node.canonical', {'node': node.id}) }}" style="font-size:9px; color:#444444;">Voir la version en ligne / View this email on the web</a>
+        <table bgcolor="#ffffff" style="margin: 0 auto; color: #444444; font-family: arial; font-size: 12px; background-color: #ffffff; float:none; position:relative;" width="600" border="0" cellspacing="0" cellpadding="0">
+          <tbody>
+            <tr>
+              <td style="text-align:left;">
+
+                {# <h2>{{ title }}</h2> #}
+                {{ build }}
+
+                <table style="margin: 0 0 0 10px; border-collapse: collapse; color: #444444; font-family: arial; font-size: 12px; border-color: #dddddd; background-color: #ffffff;">
+                  <tbody>
+                    <tr>
+                      <td style="vertical-align: top; padding: 5px 0;" width="580">
+                        <table style="border-collapse: collapse; width: 565px; color: #444444; font-family: arial; font-size: 12px; border-color: #dddddd; background-color: #ffffff;" width="565" cellspacing="0" cellpadding="0">
+                          <tbody>
+                            <tr>
+                              <td style="padding: 5px 0 5px 5px; line-height: normal;">
+                                <table width="100%" border="0" cellspacing="0" cellpadding="0">
+                                  <tbody>
+                                    <tr>
+                                      <td>
+                                        <table border="0" cellspacing="0" cellpadding="0" align="left">
+                                          <tbody>
+                                            <tr>
+                                              <td>
+                                                <table style="border-collapse: collapse; align: left;" cellspacing="0" cellpadding="0" align="left">
+                                                  <tbody>
+                                                    <tr>
+                                                      <td style="padding: 2px; margin: 0; vertical-align: top;">
+                                                        <a href="https://www.instagram.com/materio_group" target="_blank" style="display: block; border: none; text-decoration: none;">
+                                                          <img src="https://materio.com/sites/default/files/ico_social_instagram.png" alt="instagram" style="vertical-align: top; border: none;">
+                                                        </a>
+                                                      </td>
+                                                      <td style="padding: 2px; margin: 0; vertical-align: top;">
+                                                        <a href="https://www.youtube.com/channel/UChKuhMq9rSfLqUmPc9dEgXw" target="_blank" style="display: block; border: none; text-decoration: none;">
+                                                          <img src="https://materio.com/sites/default/files/ico_social_youtube.png" alt="youtube" style="vertical-align: top; border: none;">
+                                                        </a>
+                                                      </td>
+                                                      <td style="padding: 2px; margin: 0; vertical-align: top;">
+                                                        <a href="https://www.linkedin.com/company/mat-rio-sas" target="_blank" style="display: block; border: none; text-decoration: none;">
+                                                          <img src="https://materio.com/sites/default/files/ico_social_linkedin.png" alt="youtube" style="vertical-align: top; border: none;">
+                                                        </a>
+                                                      </td>
+                                                    </tr>
+                                                  </tbody>
+                                                </table>
+                                              </td>
+                                            </tr>
+                                          </tbody>
+                                        </table>
+                                      </td>
+                                    </tr>
+                                  </tbody>
+                                </table>
+                              </td>
+                            </tr>
+                          </tbody>
+                        </table>
+                      </td>
+                    </tr>
+                  </tbody>
+                </table>
+            </td>
+        </tr>
+        </tbody>
+    </table>
+    <table style="height: 10px; border-collapse: collapse; font-size: 1px;" border="0" cellspacing="0" cellpadding="0">
+        <tbody>
+        <tr>
+            <td style="height: 10px; border-spacing: 0; font-size: 1px;" height="10">
+            &nbsp;
+            </td>
+        </tr>
+        </tbody>
+    </table>
+
+{% if not opt_out_hidden %}
+    {% if format == 'html' %}
+        <p class="newsletter-footer"><a
+                    href="[simplenews-subscriber:unsubscribe-url]">{{ unsubscribe_text }}</a>
+        </p>
+    {% else %}
+        -- {{ unsubscribe_text }} : [simplenews-subscriber:unsubscribe-url]
+    {% endif %}
+{% endif %}
+
+{% if key == 'test' %}
+    - - - {{ test_message }} - - -
+{% endif %}
+
+        <p id="footer_address" style="color:#444444; text-align: center; margin: 20px 20px 0; line-height:1; font-size:10px; ">
+          matériO SAS<br>8, rue Chaptal<br>75009 Paris<br><a href="https://materio.com" style="color:#444444">materio.com</a>
+        </p>
+      </td>
+    </tr>
+  </tbody>
+</table>

+ 15 - 0
web/themes/custom/materiotheme/templates/email.html.twig

@@ -0,0 +1,15 @@
+{#
+/**
+ * @file
+ * Default theme implementation for Symfony Email.
+ *
+ * Variables:
+ * - body: Email body content.
+ *
+ * @see template_preprocess_email()
+ *
+ * @ingroup themeable
+ */
+#}
+
+{{ body }}