20 Commits

Author SHA1 Message Date
3bbc26e5b7 updated W contrib modules 2025-10-14 19:11:51 +02:00
ffa79f9872 updated V contrib modules 2025-10-14 19:08:38 +02:00
17448e4faf updated U contrib modules 2025-10-14 18:57:21 +02:00
d2dc84e54f updated T contrib modules, taxonomy_term_tree needs repatch 2025-10-14 18:44:59 +02:00
f4123bac89 updated S contrib modules, search_api simplenews 2025-10-14 17:04:08 +02:00
9d54e8c553 updated R contrib modules, role_expire upgrade 2025-10-14 16:51:00 +02:00
908c61700c updated P contrib modules, patched pwa 2025-10-14 16:35:01 +02:00
bcda2568a7 updated M contrib modules, patched mailjet 2025-10-14 16:02:11 +02:00
343760582e linkit upgrad. Mailet update, removed 2 obsolet patch, repatched simplenews_mailet_subscrition 2025-10-10 17:44:21 +02:00
7b9a2b2f67 updated I contrib modules 2025-10-10 16:36:55 +02:00
001719b583 removed image_effects contrib module & unused hd_watermark image style 2025-10-10 16:25:59 +02:00
486d73106f updated G contrib modules 2025-10-10 16:04:51 +02:00
5974397cd4 repatched flag again (peformance issues is only with home) 2025-10-09 17:52:07 +02:00
fa432d3a42 updtaed F contrib modules (flag and flag_lists. removed flag patch. fixed materio_flag custom module 2025-10-09 17:40:19 +02:00
048da51d1c updated extlink 2025-10-09 16:41:20 +02:00
8064aaa6d8 updtaed E contrib modules 2025-10-09 16:33:37 +02:00
7ca77bdd79 updtaed D contrib modules (symfony_mailer added mailer_transport) 2025-10-09 16:27:25 +02:00
cbce52ed10 updtaed C contrib modules (commerce) 2025-10-09 16:20:08 +02:00
fc6c146403 updtaed A contrib modules 2025-10-09 16:04:00 +02:00
eac6ca4e03 updated core to 10.5.4 2025-10-09 15:26:50 +02:00
54 changed files with 2533 additions and 1823 deletions

View File

@@ -89,9 +89,9 @@
"drupal/config_pages": "^2.9",
"drupal/config_split": "^2.0@beta",
"drupal/consumer_image_styles": "^4.0",
"drupal/core-composer-scaffold": "^10.3",
"drupal/core-project-message": "^10.3",
"drupal/core-recommended": "^10.3",
"drupal/core-composer-scaffold": "^10.4",
"drupal/core-project-message": "^10.4",
"drupal/core-recommended": "^10.4",
"drupal/csv_serialization": "^4.0",
"drupal/ctools": "^4.0",
"drupal/devel": "^5.0",
@@ -109,7 +109,6 @@
"drupal/google_analytics": "^4.0",
"drupal/graphql": "^4.7",
"drupal/image_delta_formatter": "^1.2",
"drupal/image_effects": "^3.6",
"drupal/jquery_ui_button": "^2.1",
"drupal/jsonapi_extras": "^3.21",
"drupal/login_history": "^2.0",
@@ -129,7 +128,7 @@
"drupal/redis": "^1.5",
"drupal/restui": "^1.16",
"drupal/role_delegation": "^1.1",
"drupal/role_expire": "^3.0",
"drupal/role_expire": "^4.1",
"drupal/rules": "^4.0",
"drupal/search_api": "^1.19",
"drupal/search_api_autocomplete": "^1.2",
@@ -147,7 +146,7 @@
"drupal/synonyms": "^2.0.0-beta2",
"drupal/telephone_formatter": "^1.0@beta",
"drupal/telephone_validation": "^2.1",
"drupal/term_reference_tree": "^2.0",
"drupal/term_reference_tree": "2.0.1",
"drupal/unique_content_field_validation": "^1.1",
"drupal/upgrade_status": "^4.3",
"drupal/user_csv_import": "^2.0",
@@ -251,18 +250,14 @@
"drupal/address": {
"Integrate Address with Search API https://www.drupal.org/project/address/issues/2812659": "https://www.drupal.org/files/issues/2020-11-02/integrate-address-searchapi-2812659-56.patch"
},
"drupal/flag": {
"remove flag hooks to allow site to be accessible again https://www.drupal.org/project/flag/issues/3200806": "./patches/flag-commenthooks.patch"
},
"drupal/mailjet": {
"DrupalmailjetControllerMailjetRegisterController::redirectRegister() does not exist https://www.drupal.org/project/mailjet/issues/3450474": "https://www.drupal.org/files/issues/2024-05-29/mailjet-15615025-5.patch",
"Error: Class MailjetTools/MailjetApi not found in Drupal/mailjet/Form/MailjetApiForm->submitForm() https://www.drupal.org/project/mailjet/issues/3464788":"https://www.drupal.org/files/issues/2024-08-20/mailjetApiForm_use_mailjettools_mailjetapi.patch",
"Error: Class MailjetTools/UsStates not found https://www.drupal.org/project/mailjet/issues/3469059":"https://www.drupal.org/files/issues/2024-08-20/mailjet_settingsform_usstates.patch"
"DrupalmailjetControllerMailjetRegisterController::redirectRegister() does not exist https://www.drupal.org/project/mailjet/issues/3450474": "https://www.drupal.org/files/issues/2024-05-29/mailjet-15615025-5.patch"
},
"drupal/pwa": {
"Manifest doesn't have a maskable icon https://www.drupal.org/project/pwa/issues/3165433": "https://www.drupal.org/files/issues/2024-03-10/manifest-doesnt-have-a-maskable-icon-error-3165433-20.patch",
"Undefined array key name https://www.drupal.org/project/pwa/issues/3422906": "https://www.drupal.org/files/issues/2024-02-21/pwa-3422906-3.patch",
"The module adds white space at the top of the olivero theme https://www.drupal.org/project/pwa/issues/3427753" : "https://www.drupal.org/files/issues/2024-04-03/pwa-pwa_extras-decode_entities.patch"
"The module adds white space at the top of the olivero theme https://www.drupal.org/project/pwa/issues/3427753" : "https://www.drupal.org/files/issues/2024-04-03/pwa-pwa_extras-decode_entities.patch",
"Error: Class Html not found in pwa_extras_page_attachments() https://www.drupal.org/project/pwa/issues/3552103": "https://www.drupal.org/files/issues/2025-10-14/pwa_utility_html_fix.patch"
},
"drupal/toolbar_theme": {
"Automated Drupal 9 compatibility fixes https://www.drupal.org/project/toolbar_themes/issues/3149099": "https://www.drupal.org/files/issues/2020-06-06/toolbar_themes.1.x-dev.rector.patch"
@@ -271,22 +266,22 @@
"Define void return type for setUp() and tearDown() methods https://gitlab.com/weitzman/drupal-test-traits/-/issues/78":"./patches/Definevoidreturntype2.patch"
},
"drupal/simplenews_mailjet_subscriptions": {
"using mailjet module":"./patches/simplenews_mailjet_subscriptions__usingmailjetmodule#3.patch"
"using mailjet module https://www.drupal.org/project/simplenews_mailjet_subscriptions/issues/3318780":"./patches/simplenews_mailjet_subscriptions__usingmailjetmodule#4.patch"
},
"drupal/graphql": {
"invalid translation language https://github.com/drupal-graphql/graphql/pull/1176": "./patches/graphql-fix-invalid-translation-language-dev.patch"
},
"drupal/user_history": {
"init batch : field_storage_values misses type https://www.drupal.org/project/user_history/issues/3311360": "https://www.drupal.org/files/issues/2022-09-23/user_history__field_storage_values__miss__type.patch"
},
"drupal/views_ef_fieldset": {
"Exposed operators are not included in fieldsets https://www.drupal.org/project/views_ef_fieldset/issues/3173822": "https://git.drupalcode.org/project/views_ef_fieldset/-/merge_requests/1/diffs.patch"
},
"drupal/term_reference_tree": {
"Term Reference Tree: Re-implement Track List https://www.drupal.org/project/term_reference_tree/issues/3064280": "https://www.drupal.org/files/issues/2024-08-26/term_reference_tree-3064280_bring_back_tracklist-22.patch"
},
"drupal/advancedqueue": {
"Issue with configuration schema advancedqueue.backend.[id] https://www.drupal.org/project/advancedqueue/issues/3469869": "https://git.drupalcode.org/project/advancedqueue/-/commit/a8864851cdfa40c9e38a3f5f64885baf1937375e.patch"
"drupal/flag": {
"remove flag hooks to allow site to be accessible again https://www.drupal.org/project/flag/issues/3200806": "./patches/flag-commenthooks.patch"
},
"drupal/mailjet": {
"MailjetConfigurationAccessCheck blocks access to all pages for users except admin https://www.drupal.org/project/mailjet/issues/3539776": "https://www.drupal.org/files/issues/2025-08-05/0001-fix-mailjetconfigurationaccesscheck-blocking-access.patch"
}
},
"archived-patches": {
@@ -309,6 +304,16 @@
},
"drupal/mailjet": {
"https://www.drupal.org/project/mailjet/issues/3325412":"https://www.drupal.org/files/issues/2022-12-05/mailjet-list_instead_of_listid.patch"
},
"drupal/advancedqueue": {
"Issue with configuration schema advancedqueue.backend.[id] https://www.drupal.org/project/advancedqueue/issues/3469869": "https://git.drupalcode.org/project/advancedqueue/-/commit/a8864851cdfa40c9e38a3f5f64885baf1937375e.patch"
},
"drupal/mailjet": {
"Error: Class MailjetTools/MailjetApi not found in Drupal/mailjet/Form/MailjetApiForm->submitForm() https://www.drupal.org/project/mailjet/issues/3464788":"https://www.drupal.org/files/issues/2024-08-20/mailjetApiForm_use_mailjettools_mailjetapi.patch",
"Error: Class MailjetTools/UsStates not found https://www.drupal.org/project/mailjet/issues/3469059":"https://www.drupal.org/files/issues/2024-08-20/mailjet_settingsform_usstates.patch"
},
"drupal/user_history": {
"init batch : field_storage_values misses type https://www.drupal.org/project/user_history/issues/3311360": "https://www.drupal.org/files/issues/2022-09-23/user_history__field_storage_values__miss__type.patch"
}
},
"drupal-scaffold": {

3188
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -8,7 +8,7 @@ title: 'Update indexes'
id: update_cron
weight: 0
module: update
callback: update_cron
callback: 'update#cron'
scheduler:
id: simple
launcher:

View File

@@ -1 +1,5 @@
menu_depth: 4
hoverintent_behavior:
enabled: true
timeout: 500
enable_toggle_shortcut: false

View File

@@ -61,6 +61,7 @@ content:
third_party_settings: { }
hidden:
created: true
customer_comments: true
field_mailjet_campaign_id: true
field_mailjet_campaign_name: true
ip_address: true

View File

@@ -66,13 +66,21 @@ content:
weight: 2
region: content
coupons:
label: above
type: entity_reference_label
label: above
settings:
link: true
region: content
weight: 10
third_party_settings: { }
weight: 10
region: content
customer_comments:
type: string
label: above
settings:
link_to_entity: false
third_party_settings: { }
weight: 11
region: content
ip_address:
type: string
label: inline

View File

@@ -47,13 +47,21 @@ content:
weight: 2
region: content
coupons:
label: above
type: entity_reference_label
label: above
settings:
link: true
region: content
weight: 7
third_party_settings: { }
weight: 7
region: content
customer_comments:
type: string
label: above
settings:
link_to_entity: false
third_party_settings: { }
weight: 8
region: content
mail:
type: basic_string
label: inline

View File

@@ -102,7 +102,6 @@ module:
honeypot: 0
image: 0
image_delta_formatter: 0
image_effects: 0
imagemagick: 0
images_styles_gen: 0
inline_entity_form: 0
@@ -114,6 +113,7 @@ module:
jquery_ui_datepicker: 0
jquery_ui_slider: 0
jquery_ui_touch_punch: 0
js_cookie: 0
jsonapi: 0
jsonapi_extras: 0
language: 0
@@ -125,6 +125,7 @@ module:
login_history: 0
login_tracker: 0
logout_token: 0
mailer_transport: 0
mailjet: 0
mailjet_commerce: 0
mailjet_event: 0
@@ -173,6 +174,7 @@ module:
restui: 0
role_delegation: 0
role_expire: 0
role_expire_rules: 0
rules: 0
search_api: 0
search_api_db: 0

View File

@@ -5,24 +5,35 @@ extlink_use_external_js_file: false
extlink_exclude_admin_routes: false
extlink_target: false
extlink_target_no_override: false
extlink_target_display_default_title: true
extlink_target_default_title_text: '(opens in a new window)'
extlink_title_no_override: false
extlink_nofollow: false
extlink_noreferrer: false
extlink_follow_no_override: false
extlink_subdomains: true
extlink_alert: false
extlink_alert_text: 'This link will take you to an external web site. We are not responsible for their content.'
extlink_additional_link_classes: ''
extlink_additional_mailto_classes: ''
extlink_additional_tel_classes: ''
extlink_exclude: ''
extlink_include: ''
extlink_exclude_noreferrer: ''
extlink_class: ext
extlink_label: '(link is external)'
extlink_img_class: false
extlink_css_exclude: .social-media-links--platforms
extlink_css_include: ''
extlink_css_explicit: ''
extlink_mailto_class: mailto
extlink_mailto_label: '(link sends email)'
extlink_tel_class: ''
extlink_tel_label: '(link is a phone number)'
extlink_use_font_awesome: false
extlink_font_awesome_classes:
links: 'fa fa-external-link'
mailto: 'fa fa-envelope-o'
extlink_icon_placement: '0'
whitelisted_domains: { }
extlink_prevent_orphan: false
allowed_domains: { }

View File

@@ -1,5 +1,5 @@
uuid: 9a1c075d-72f0-456f-a1fa-501acb90db95
langcode: und
langcode: en
status: true
dependencies:
module:

View File

@@ -1,29 +0,0 @@
uuid: 8722930b-22a2-4f06-afb0-593c9969c185
langcode: en
status: true
dependencies:
module:
- image_effects
name: hd_watermark
label: 'hd watermark (1920x1080)'
effects:
94be638b-57fe-4848-8ac3-95036ece001c:
uuid: 94be638b-57fe-4848-8ac3-95036ece001c
id: image_scale
weight: 1
data:
width: 1920
height: 1200
upscale: false
07af5abf-4bb7-4e96-ba86-9fe6e92ab548:
uuid: 07af5abf-4bb7-4e96-ba86-9fe6e92ab548
id: image_effects_watermark
weight: 2
data:
watermark_image: sites/default/files/watermarks/materio-watermark-hd.png
watermark_width: 90%
watermark_height: ''
placement: center-center
x_offset: ''
y_offset: ''
opacity: 10

View File

@@ -1,17 +0,0 @@
_core:
default_config_hash: eaXmaPSud65p-XhTwMIL9vKETD9zR3qNOMMa5EUuoNw
color_selector:
plugin_id: farbtastic
plugin_settings:
html_color: { }
farbtastic: { }
image_selector:
plugin_id: dropdown
plugin_settings:
basic: { }
dropdown:
path: sites/default/files/watermarks
font_selector:
plugin_id: basic
plugin_settings:
basic: { }

View File

@@ -53,3 +53,4 @@ advanced:
colorspace: '0'
profile: ''
coalesce: false
imagemagick_version: v6

View File

@@ -12,8 +12,6 @@ display:
sort_desc_label: Desc
fields:
quantity:
alter:
text: '{{ quantity }} x'
separator: ', '
title:
separator: ', '

View File

@@ -4,3 +4,4 @@ role_expire_default_roles: '{"unverified":"0","free_user":"0","contact_company":
role_expire_disabled_roles: '{"unverified":1,"free_user":1,"contact_company":1,"alpha_testeur":1,"student":0,"adherent":1,"translator":1,"admin_showroom":1,"admin":1,"root":1}'
role_expire_default_duration_roles:
student: '1 year'
role_expire_expiration_details_expanded: false

View File

@@ -7,9 +7,8 @@ dependencies:
- search_api.server.database_search_autocomplete
module:
- search_api_solr
- taxonomy
- synonyms
- search_api
- taxonomy
third_party_settings:
search_api_solr:
finalize: false

View File

@@ -10,17 +10,16 @@ dependencies:
- field.storage.node.field_reference
- field.storage.node.field_short_description
- field.storage.node.field_tags
- field.storage.taxonomy_term.field_synonyms
- field.storage.node.field_thesaurus
- field.storage.taxonomy_term.field_synonyms
- search_api.server.materio
module:
- search_api_solr
- materio_sapi
- taxonomy
- node
- synonyms
- search_api
- address
- materio_sapi
- node
- search_api_solr
- synonyms
- taxonomy
third_party_settings:
search_api_solr:
finalize: true

View File

@@ -4,8 +4,6 @@ status: true
dependencies: { }
id: '19125'
title: ZeDaily
api_key: null
secret_key: null
mapping_table:
-
simplenews_news: ze_daily_materio_

View File

@@ -4,8 +4,6 @@ status: true
dependencies: { }
id: '22839'
title: "materio' newsletter"
api_key: null
secret_key: null
mapping_table:
-
simplenews_news: materio_newsletter

View File

@@ -4,8 +4,6 @@ status: true
dependencies: { }
id: '24787'
title: Compagnie
api_key: null
secret_key: null
mapping_table:
-
simplenews_news: companies

View File

@@ -0,0 +1,10 @@
langcode: en
status: true
dependencies:
module:
- simplenews
id: simplenews_subscriber_delete_action
label: 'Delete subscriber'
type: simplenews_subscriber
plugin: 'entity:delete_action:simplenews_subscriber'
configuration: { }

View File

@@ -8,7 +8,7 @@ title: 'Default cron handler'
id: advancedqueue_cron
weight: 0
module: advancedqueue
callback: advancedqueue_cron
callback: 'advancedqueue#cron'
scheduler:
id: simple
launcher:

View File

@@ -8,7 +8,7 @@ title: 'Default cron handler'
id: commerce_cart_cron
weight: 0
module: commerce_cart
callback: commerce_cart_cron
callback: 'commerce_cart#cron'
scheduler:
id: simple
launcher:

View File

@@ -8,7 +8,7 @@ title: 'Default cron handler'
id: commerce_cron
weight: 0
module: commerce
callback: commerce_cron
callback: 'commerce#cron'
scheduler:
id: simple
launcher:

View File

@@ -8,7 +8,7 @@ title: 'Default cron handler'
id: commerce_license_cron
weight: 0
module: commerce_license
callback: commerce_license_cron
callback: 'commerce_license#cron'
scheduler:
id: simple
launcher:

View File

@@ -8,7 +8,7 @@ title: 'Default cron handler'
id: commerce_promotion_cron
weight: 0
module: commerce_promotion
callback: commerce_promotion_cron
callback: 'commerce_promotion#cron'
scheduler:
id: simple
launcher:

View File

@@ -8,7 +8,7 @@ title: 'Default cron handler'
id: commerce_recurring_cron
weight: 0
module: commerce_recurring
callback: commerce_recurring_cron
callback: 'commerce_recurring#cron'
scheduler:
id: simple
launcher:

View File

@@ -8,7 +8,7 @@ title: 'Default cron handler'
id: content_lock_timeout_cron
weight: 0
module: content_lock_timeout
callback: content_lock_timeout_cron
callback: 'content_lock_timeout#cron'
scheduler:
id: simple
launcher:

View File

@@ -8,7 +8,7 @@ title: 'Remove expired log messages and flood control events'
id: dblog_cron
weight: 0
module: dblog
callback: dblog_cron
callback: 'dblog#cron'
scheduler:
id: simple
launcher:

View File

@@ -8,7 +8,7 @@ title: 'Purges deleted Field API data'
id: field_cron
weight: 0
module: field
callback: field_cron
callback: 'field#cron'
scheduler:
id: simple
launcher:

View File

@@ -8,7 +8,7 @@ title: 'Deletes temporary files'
id: file_cron
weight: 0
module: file
callback: file_cron
callback: 'file#cron'
scheduler:
id: simple
launcher:

View File

@@ -8,7 +8,7 @@ title: 'Default cron handler'
id: honeypot_cron
weight: 0
module: honeypot
callback: honeypot_cron
callback: 'honeypot#cron'
scheduler:
id: simple
launcher:

View File

@@ -8,7 +8,7 @@ title: 'Default cron handler'
id: locale_cron
weight: 0
module: locale
callback: locale_cron
callback: 'locale#cron'
scheduler:
id: simple
launcher:

View File

@@ -8,7 +8,7 @@ title: 'Default cron handler'
id: login_history_cron
weight: 0
module: login_history
callback: login_history_cron
callback: 'login_history#cron'
scheduler:
id: simple
launcher:

View File

@@ -8,7 +8,7 @@ title: 'Default cron handler'
id: login_tracker_cron
weight: 0
module: login_tracker
callback: login_tracker_cron
callback: 'login_tracker#cron'
scheduler:
id: simple
launcher:

View File

@@ -8,7 +8,7 @@ title: 'Default cron handler'
id: materio_home_cron
weight: 0
module: materio_home
callback: materio_home_cron
callback: 'materio_home#cron'
scheduler:
id: simple
configuration:

View File

@@ -8,7 +8,7 @@ title: 'Default cron handler'
id: message_cron
weight: 0
module: message
callback: message_cron
callback: 'message#cron'
scheduler:
id: simple
launcher:

View File

@@ -8,7 +8,7 @@ title: 'Mark old nodes as read'
id: node_cron
weight: 0
module: node
callback: node_cron
callback: 'node#cron'
scheduler:
id: simple
launcher:

View File

@@ -8,7 +8,7 @@ title: 'Default cron handler'
id: role_expire_cron
weight: 0
module: role_expire
callback: role_expire_cron
callback: 'role_expire#cron'
scheduler:
id: simple
launcher:

View File

@@ -8,7 +8,7 @@ title: 'Default cron handler'
id: rules_cron
weight: 0
module: rules
callback: rules_cron
callback: 'rules#cron'
scheduler:
id: simple
launcher:

View File

@@ -8,7 +8,7 @@ title: 'Default cron handler'
id: search_api_cron
weight: 0
module: search_api
callback: search_api_cron
callback: 'search_api#cron'
scheduler:
id: simple
launcher:

View File

@@ -8,7 +8,7 @@ title: 'Default cron handler'
id: search_api_solr_cron
weight: 0
module: search_api_solr
callback: search_api_solr_cron
callback: 'search_api_solr#cron'
scheduler:
id: simple
launcher:

View File

@@ -10,7 +10,7 @@ title: 'Sends newsletters'
id: simplenews_cron
weight: 0
module: simplenews
callback: simplenews_cron
callback: 'simplenews#cron'
scheduler:
id: simple
configuration:

View File

@@ -8,7 +8,7 @@ title: 'Cleanup (caches, batch, flood, temp-files, etc.)'
id: system_cron
weight: 0
module: system
callback: system_cron
callback: 'system#cron'
scheduler:
id: simple
launcher:

View File

@@ -6,7 +6,7 @@ title: 'Runs internal cleanup operations'
id: ultimate_cron_cron
weight: 0
module: ultimate_cron
callback: ultimate_cron_cron
callback: 'ultimate_cron#cron'
scheduler:
id: simple
launcher:

View File

@@ -8,7 +8,7 @@ title: 'Default cron handler'
id: user_email_verification_cron
weight: 0
module: user_email_verification
callback: user_email_verification_cron
callback: 'user_email_verification#cron'
scheduler:
id: simple
configuration:

View File

@@ -8,7 +8,7 @@ title: 'Default cron handler'
id: user_history_cron
weight: 0
module: user_history
callback: user_history_cron
callback: 'user_history#cron'
scheduler:
id: simple
launcher:

View File

@@ -8,7 +8,7 @@ title: 'Default cron handler'
id: webform_cron
weight: 0
module: webform
callback: webform_cron
callback: 'webform#cron'
scheduler:
id: simple
launcher:

View File

@@ -8,7 +8,7 @@ title: 'Default cron handler'
id: workflow_cron
weight: 0
module: workflow
callback: workflow_cron
callback: 'workflow#cron'
scheduler:
id: simple
launcher:

View File

@@ -1,12 +1,12 @@
diff --git a/flag.module b/flag.module
index 8dd6181..d67cc8a 100644
index d82c105..427ed09 100644
--- a/flag.module
+++ b/flag.module
@@ -342,82 +342,82 @@ function flag_node_links_alter(array &$links, NodeInterface $entity, array &$con
@@ -332,85 +332,85 @@ function flag_build_entity_links(array &$links, EntityInterface $entity, array &
*
* Handles the 'show_in_links' and 'show_as_field' flag options.
*/
-function flag_entity_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
-function flag_entity_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, ?string $view_mode = NULL) {
- // Don't show on previews.
- if ($entity->isNew()) {
- return;
@@ -26,10 +26,11 @@ index 8dd6181..d67cc8a 100644
- $build['#cache']['tags'] = Cache::mergeTags($build['#cache']['tags'], $flag->getCacheTags());
-
- // Do not display the flag if disabled.
- if (!$flag->status()){
- if (!$flag->status()) {
- continue;
- }
-
- /** @var \Drupal\flag\Plugin\Flag\EntityFlagType $flag_type_plugin */
- $flag_type_plugin = $flag->getFlagTypePlugin();
-
- // Only add cache key if flag link is displayed.
@@ -42,48 +43,53 @@ index 8dd6181..d67cc8a 100644
- $entity->getEntityTypeId(),
- $entity->id(),
- $flag->id(),
- ]],
- $view_mode,
- ],
- ],
- '#create_placeholder' => TRUE,
- ];
- }
-}
+// function flag_entity_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
+// function flag_entity_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, ?string $view_mode = NULL) {
+// // Don't show on previews.
+// if ($entity->isNew()) {
+// return;
+// }
+//
+
+// $build['#cache']['contexts'][] = 'user.permissions';
+//
+
+// if (empty($build['#cache']['tags'])) {
+// $build['#cache']['tags'] = [];
+// }
+//
+
+// // Get all possible flags for this entity type.
+// $flag_service = \Drupal::service('flag');
+// $flags = $flag_service->getAllFlags($entity->getEntityTypeID(), $entity->bundle());
+//
+
+// foreach ($flags as $flag) {
+// $build['#cache']['tags'] = Cache::mergeTags($build['#cache']['tags'], $flag->getCacheTags());
+//
+
+// // Do not display the flag if disabled.
+// if (!$flag->status()){
+// if (!$flag->status()) {
+// continue;
+// }
+//
+
+// /** @var \Drupal\flag\Plugin\Flag\EntityFlagType $flag_type_plugin */
+// $flag_type_plugin = $flag->getFlagTypePlugin();
+//
+
+// // Only add cache key if flag link is displayed.
+// if (!$flag_type_plugin->showAsField() || !$display->getComponent('flag_' . $flag->id())) {
+// continue;
+// }
+//
+
+// $build['flag_' . $flag->id()] = [
+// '#lazy_builder' => ['flag.link_builder:build', [
+// $entity->getEntityTypeId(),
+// $entity->id(),
+// $flag->id(),
+// ]],
+// $view_mode,
+// ],
+// ],
+// '#create_placeholder' => TRUE,
+// ];
+// }
@@ -95,69 +101,62 @@ index 8dd6181..d67cc8a 100644
-function flag_entity_build_defaults_alter(array &$build, EntityInterface $entity, $view_mode = 'full', $langcode = NULL) {
- /** @var \Drupal\flag\FlagService $flag_service */
- $flag_service = \Drupal::service('flag');
-
+// function flag_entity_build_defaults_alter(array &$build, EntityInterface $entity, $view_mode = 'full', $langcode = NULL) {
+// /** @var \Drupal\flag\FlagService $flag_service */
+// $flag_service = \Drupal::service('flag');
- // Get all possible flags for this entity type.
- $flags = $flag_service->getAllFlags($entity->getEntityTypeId(), $entity->bundle());
-
+// // Get all possible flags for this entity type.
+// $flags = $flag_service->getAllFlags($entity->getEntityTypeId(), $entity->bundle());
- $no_cache = FALSE;
- foreach ($flags as $flag) {
- $flag_type_plugin = $flag->getFlagTypePlugin();
-
+// $no_cache = FALSE;
+// foreach ($flags as $flag) {
+// $flag_type_plugin = $flag->getFlagTypePlugin();
- // Make sure we're dealing with an entity flag type.
- if (!$flag_type_plugin instanceof EntityFlagType) {
- continue;
- }
-
+// // Make sure we're dealing with an entity flag type.
+// if (!$flag_type_plugin instanceof EntityFlagType) {
+// continue;
+// }
- // Only add max-age to entity render array if contextual links flag
- // display is enabled.
- if (!$flag_type_plugin->showContextualLink()) {
- continue;
- }
-
- $no_cache = TRUE;
- }
-
- if ($no_cache) {
- $build['#cache']['max-age'] = 0;
- }
-
- return $build;
-}
+// function flag_entity_build_defaults_alter(array &$build, EntityInterface $entity, $view_mode = 'full', $langcode = NULL) {
+// /** @var \Drupal\flag\FlagService $flag_service */
+// $flag_service = \Drupal::service('flag');
+//
+// // Get all possible flags for this entity type.
+// $flags = $flag_service->getAllFlags($entity->getEntityTypeId(), $entity->bundle());
+//
+// $no_cache = FALSE;
+// foreach ($flags as $flag) {
+// $flag_type_plugin = $flag->getFlagTypePlugin();
+//
+// // Make sure we're dealing with an entity flag type.
+// if (!$flag_type_plugin instanceof EntityFlagType) {
+// continue;
+// }
+//
+// // Only add max-age to entity render array if contextual links flag
+// // display is enabled.
+// if (!$flag_type_plugin->showContextualLink()) {
+// continue;
+// }
+//
- $no_cache = TRUE;
- }
+// $no_cache = TRUE;
+// }
+//
- if ($no_cache) {
- $build['#cache']['max-age'] = 0;
- }
+// if ($no_cache) {
+// $build['#cache']['max-age'] = 0;
+// }
+//
- return $build;
-}
+// return $build;
+// }
/**
* Implements hook_entity_view_alter().
@@ -425,41 +425,41 @@ function flag_entity_build_defaults_alter(array &$build, EntityInterface $entity
@@ -418,48 +418,48 @@ function flag_entity_build_defaults_alter(array &$build, EntityInterface $entity
* Alters node contextual links placeholder id to contain flag metadata, so that
* contextual links cache considers flags granularity.
*/
@@ -178,7 +177,7 @@ index 8dd6181..d67cc8a 100644
- continue;
- }
-
- // Only apply metadata to contextual links if plugin is enabled
- // Only apply metadata to contextual links if plugin is enabled.
- if (!$flag_type_plugin->showContextualLink()) {
- continue;
- }
@@ -192,44 +191,58 @@ index 8dd6181..d67cc8a 100644
- }
-
- if (!empty($flag_keys)) {
- $build['#contextual_links'][$entity_type]['route_parameters']['view_mode'] = $build['#view_mode'];
- $build['#contextual_links'][$entity_type]['metadata']['flag_keys'] = implode(',', $flag_keys);
- }
- }
-
- // Enable placeholder on entity links to avoid them being cached with the
- // entity view mode.
- if (isset($build['links']['#lazy_builder'])) {
- $build['links']['#create_placeholder'] = TRUE;
- }
-}
+// function flag_entity_view_alter(&$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
+// $entity_type = $entity->getEntityTypeId();
+// if (isset($build['#contextual_links'][$entity_type])) {
+// /** @var \Drupal\flag\FlagService $flag_service */
+// $flag_service = \Drupal::service('flag');
+//
+
+// // Get all possible flags for this entity type.
+// $flags = $flag_service->getAllFlags($entity_type, $entity->bundle());
+//
+
+// foreach ($flags as $flag) {
+// $flag_type_plugin = $flag->getFlagTypePlugin();
+//
+
+// // Make sure we're dealing with an entity flag type.
+// if (!$flag_type_plugin instanceof EntityFlagType) {
+// continue;
+// }
+//
+// // Only apply metadata to contextual links if plugin is enabled
+
+// // Only apply metadata to contextual links if plugin is enabled.
+// if (!$flag_type_plugin->showContextualLink()) {
+// continue;
+// }
+//
+
+// $action = 'flag';
+// if ($flag->isFlagged($entity)) {
+// $action = 'unflag';
+// }
+//
+
+// $flag_keys[] = $flag->id() . '-' . $action;
+// }
+//
+
+// if (!empty($flag_keys)) {
+// $build['#contextual_links'][$entity_type]['route_parameters']['view_mode'] = $build['#view_mode'];
+// $build['#contextual_links'][$entity_type]['metadata']['flag_keys'] = implode(',', $flag_keys);
+// }
+// }
+
+// // Enable placeholder on entity links to avoid them being cached with the
+// // entity view mode.
+// if (isset($build['links']['#lazy_builder'])) {
+// $build['links']['#create_placeholder'] = TRUE;
+// }
+// }
/**

View File

@@ -0,0 +1,794 @@
diff --git a/README.txt b/README.txt
index cee6e1a..b488e91 100644
--- a/README.txt
+++ b/README.txt
@@ -15,6 +15,7 @@ REQUIREMENTS
This module requires the following modules:
* Simplenews (https://www.drupal.org/project/simplenews)
+ * Mailet (https://www.drupal.org/project/Mailjet)
INSTALLATION
------------
diff --git a/simplenews_mailjet_subscriptions.module b/simplenews_mailjet_subscriptions.module
index 09abe13..74214f6 100644
--- a/simplenews_mailjet_subscriptions.module
+++ b/simplenews_mailjet_subscriptions.module
@@ -7,7 +7,7 @@
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\simplenews\Entity\Subscriber;
-use Drupal\simplenews_mailjet_subscriptions\SimplenewsMailjetSubscriptionsUtilities;
+// use Drupal\simplenews_mailjet_subscriptions\SimplenewsMailjetSubscriptionsUtilities;
use Drupal\simplenews_mailjet_subscriptions\Entity\SimplenewsMailjetSubscriptionEntity;
use Drupal\Component\Utility\Html;
@@ -24,18 +24,18 @@ use Drupal\Component\Utility\Html;
function simplenews_mailjet_subscriptions_simplenews_subscribe(Subscriber $subscriber, string $subscription) {
$entities = SimplenewsMailjetSubscriptionEntity::loadMultiple();
foreach ((array) $entities as $entity) {
- $api_key = $entity->getApiKey();
- $secret_key = $entity->getSecretkey();
$listID = $entity->getID();
$table = $entity->get('mapping_table');
if (is_array($table)) {
foreach ($table as $category) {
if ($category['simplenews_news'] == $subscription) {
- SimplenewsMailjetSubscriptionsUtilities::subscribeUser($subscriber, $subscription, $category, $api_key, $secret_key, $listID);
+ // SimplenewsMailjetSubscriptionsUtilities::subscribeUser($subscriber, $category);
+ \Drupal::service('simplenews_mailjet_subscriptions.utilities')->subscribeUser($listID, $subscriber, $category);
}
}
}
}
+ // \Drupal::service('simplenews_mailjet_subscriptions.utilities')->subscribeUser($subscriber, $subscription);
}
/**
@@ -51,19 +51,74 @@ function simplenews_mailjet_subscriptions_simplenews_subscribe(Subscriber $subsc
function simplenews_mailjet_subscriptions_simplenews_unsubscribe(Subscriber $subscriber, string $subscription) {
$entities = SimplenewsMailjetSubscriptionEntity::loadMultiple();
foreach ((array) $entities as $entity) {
- $api_key = $entity->getApiKey();
- $secret_key = $entity->getSecretkey();
$listID = $entity->getID();
$table = $entity->get('mapping_table');
if (is_array($table)) {
foreach ($table as $category) {
if ($category['simplenews_news'] == $subscription) {
// Unsubscribe.
- SimplenewsMailjetSubscriptionsUtilities::unsubscribeUser($subscriber, $subscription, $category, $api_key, $secret_key, $listID);
+ // SimplenewsMailjetSubscriptionsUtilities::unsubscribeUser($subscriber, $category);
+ \Drupal::service('simplenews_mailjet_subscriptions.utilities')->unsubscribeUser($listID, $subscriber, $category);
}
}
}
}
+ // \Drupal::service('simplenews_mailjet_subscriptions.utilities')->unsubscribeUser($subscriber, $subscription);
+}
+
+
+/**
+ * Act after a subscriber is updated.
+ *
+ * @param \Drupal\simplenews\Entity\Subscriber $subscriber
+ * The subscriber object including all subscriptions of this user.
+ *
+ * @ingroup subscriber
+ */
+function simplenews_mailjet_subscriptions_simplenews_subscriber_update(Subscriber $subscriber) {
+ $new_mail=$subscriber->getMail();
+ $original_mail = $subscriber->original->getMail();
+ if ($new_mail !== $original_mail) {
+ $new_subscriptions = $subscriber->getSubscribedNewsletterIds();
+ $original_subscriptions = $subscriber->original->getSubscribedNewsletterIds();
+ $entities = SimplenewsMailjetSubscriptionEntity::loadMultiple();
+ foreach ((array) $entities as $entity) {
+ $listID = $entity->getID();
+ $table = $entity->get('mapping_table');
+ if (is_array($table)) {
+ foreach ($table as $category) {
+ if ( in_array($category['simplenews_news'], $original_subscriptions) ) {
+ \Drupal::service('simplenews_mailjet_subscriptions.utilities')->unsubscribeUser($listID, $subscriber->original, $category);
+ }
+ if ( in_array($category['simplenews_news'], $new_subscriptions) ) {
+ \Drupal::service('simplenews_mailjet_subscriptions.utilities')->subscribeUser($listID, $subscriber, $category);
+ }
+ }
+ }
+ }
+ }
+}
+
+
+/**
+ * Act after a subscriber has been deleted.
+ *
+ * @param \Drupal\simplenews\Entity\Subscriber $subscriber
+ * The subscriber object including all subscriptions of this user.
+ *
+ * @ingroup subscriber
+ */
+function simplenews_mailjet_subscriptions_simplenews_subscriber_delete(Subscriber $subscriber) {
+ $entities = SimplenewsMailjetSubscriptionEntity::loadMultiple();
+ foreach ((array) $entities as $entity) {
+ $listID = $entity->getID();
+ $table = $entity->get('mapping_table');
+ if (is_array($table)) {
+ foreach ($table as $category) {
+ \Drupal::service('simplenews_mailjet_subscriptions.utilities')->unsubscribeUser($listID, $subscriber, $category);
+ }
+ }
+ }
}
/**
diff --git a/simplenews_mailjet_subscriptions.services.yml b/simplenews_mailjet_subscriptions.services.yml
new file mode 100644
index 0000000..cee6a81
--- /dev/null
+++ b/simplenews_mailjet_subscriptions.services.yml
@@ -0,0 +1,7 @@
+services:
+ simplenews_mailjet_subscriptions.handler:
+ class: Drupal\simplenews_mailjet_subscriptions\SimplenewsMailjetSubscriptionsMailjetHandler
+ arguments: ['@mailjet.factory']
+ simplenews_mailjet_subscriptions.utilities:
+ class: Drupal\simplenews_mailjet_subscriptions\SimplenewsMailjetSubscriptionsUtilities
+ arguments: [ '@simplenews_mailjet_subscriptions.handler' ]
diff --git a/src/Entity/SimplenewsMailjetSubscriptionEntity.php b/src/Entity/SimplenewsMailjetSubscriptionEntity.php
index 27b7737..34c8df5 100644
--- a/src/Entity/SimplenewsMailjetSubscriptionEntity.php
+++ b/src/Entity/SimplenewsMailjetSubscriptionEntity.php
@@ -30,8 +30,6 @@ use Drupal\Core\Config\Entity\ConfigEntityBase;
* config_export = {
* "id",
* "title",
- * "api_key",
- * "secret_key",
* "mapping_table"
* }
* )
@@ -94,53 +92,53 @@ class SimplenewsMailjetSubscriptionEntity extends ConfigEntityBase implements Si
return $this->get('id');
}
- /**
- * Returns the entity api key.
- *
- * @return string
- * The entity api key.
- */
- public function getApiKey() {
- return $this->get('api_key');
- }
-
- /**
- * Sets the entity api key.
- *
- * @param string $api_key
- * Api key.
- *
- * @return $this
- * The Simplenews Mailjet Subscription entity.
- */
- public function setApiKey($api_key) {
- $this->set('api_key', $api_key);
- return $this;
- }
-
- /**
- * Returns the entity secret key.
- *
- * @return string
- * The entity secret key.
- */
- public function getSecretkey() {
- return $this->get('secret_key');
- }
-
- /**
- * Sets the entity secret key.
- *
- * @param string $secret_key
- * Secret key.
- *
- * @return $this
- * The Simplenews Mailjet Subscription entity.
- */
- public function setSecretkey($secret_key) {
- $this->set('secret_key', $secret_key);
- return $this;
- }
+ // /**
+ // * Returns the entity api key.
+ // *
+ // * @return string
+ // * The entity api key.
+ // */
+ // public function getApiKey() {
+ // return $this->get('api_key');
+ // }
+
+ // /**
+ // * Sets the entity api key.
+ // *
+ // * @param string $api_key
+ // * Api key.
+ // *
+ // * @return $this
+ // * The Simplenews Mailjet Subscription entity.
+ // */
+ // public function setApiKey($api_key) {
+ // $this->set('api_key', $api_key);
+ // return $this;
+ // }
+
+ // /**
+ // * Returns the entity secret key.
+ // *
+ // * @return string
+ // * The entity secret key.
+ // */
+ // public function getSecretkey() {
+ // return $this->get('secret_key');
+ // }
+
+ // /**
+ // * Sets the entity secret key.
+ // *
+ // * @param string $secret_key
+ // * Secret key.
+ // *
+ // * @return $this
+ // * The Simplenews Mailjet Subscription entity.
+ // */
+ // public function setSecretkey($secret_key) {
+ // $this->set('secret_key', $secret_key);
+ // return $this;
+ // }
/**
* Sets the entity mapping table.
diff --git a/src/Form/SimplenewsMailjetSubscriptionAddForm.php b/src/Form/SimplenewsMailjetSubscriptionAddForm.php
index 836bee3..bc70090 100644
--- a/src/Form/SimplenewsMailjetSubscriptionAddForm.php
+++ b/src/Form/SimplenewsMailjetSubscriptionAddForm.php
@@ -64,20 +64,20 @@ class SimplenewsMailjetSubscriptionAddForm extends EntityForm {
'exists' => [$this, 'exist'],
],
];
- $form['api_key'] = [
- '#type' => 'textfield',
- '#title' => $this->t('API Key'),
- '#maxlength' => 32,
- '#description' => $this->t('Mailjet Account API Key'),
- '#required' => TRUE,
- ];
- $form['secret_key'] = [
- '#type' => 'password',
- '#title' => $this->t('Secret Key'),
- '#maxlength' => 32,
- '#description' => $this->t('Mailjet Account Secret Key'),
- '#required' => TRUE,
- ];
+ // $form['api_key'] = [
+ // '#type' => 'textfield',
+ // '#title' => $this->t('API Key'),
+ // '#maxlength' => 32,
+ // '#description' => $this->t('Mailjet Account API Key'),
+ // '#required' => TRUE,
+ // ];
+ // $form['secret_key'] = [
+ // '#type' => 'password',
+ // '#title' => $this->t('Secret Key'),
+ // '#maxlength' => 32,
+ // '#description' => $this->t('Mailjet Account Secret Key'),
+ // '#required' => TRUE,
+ // ];
return $form;
}
diff --git a/src/Form/SimplenewsMailjetSubscriptionEditForm.php b/src/Form/SimplenewsMailjetSubscriptionEditForm.php
index 98342b5..f67ba96 100644
--- a/src/Form/SimplenewsMailjetSubscriptionEditForm.php
+++ b/src/Form/SimplenewsMailjetSubscriptionEditForm.php
@@ -76,20 +76,20 @@ class SimplenewsMailjetSubscriptionEditForm extends EntityForm {
'#help' => $this->t('Configuration title'),
'#required' => TRUE,
];
- $form['api_key'] = [
- '#type' => 'textfield',
- '#title' => $this->t('API Key'),
- '#maxlength' => 32,
- '#default_value' => $this->entity->getApiKey(),
- '#help' => $this->t('Mailjet Account API Key'),
- '#required' => TRUE,
- '#disabled' => !$this->entity->isNew(),
- ];
-
- if ($this->entity->getApiKey() && $this->entity->getSecretkey()) {
+ // $form['api_key'] = [
+ // '#type' => 'textfield',
+ // '#title' => $this->t('API Key'),
+ // '#maxlength' => 32,
+ // '#default_value' => $this->entity->getApiKey(),
+ // '#help' => $this->t('Mailjet Account API Key'),
+ // '#required' => TRUE,
+ // '#disabled' => !$this->entity->isNew(),
+ // ];
+
+ // if ($this->entity->getApiKey() && $this->entity->getSecretkey()) {
$this->constructTable($form, $form_state);
- }
+ // }
$form['add_subscription'] = [
'#type' => 'submit',
diff --git a/src/Plugin/RulesAction/UnsubscribeFromList.php b/src/Plugin/RulesAction/UnsubscribeFromList.php
new file mode 100644
index 0000000..3f546ef
--- /dev/null
+++ b/src/Plugin/RulesAction/UnsubscribeFromList.php
@@ -0,0 +1,51 @@
+<?php
+
+namespace Drupal\simplenews_mailjet_subscriptions\Plugin\RulesAction;
+
+use Drupal\rules\Core\RulesActionBase;
+use Drupal\simplenews\SubscriberInterface;
+
+/**
+ * Provides a 'Unsubscribe' action.
+ *
+ * @RulesAction(
+ * id = "rules_simplenews_mailjet_subscriptions_unsubscribe_from_list",
+ * label = @Translation("Unsubscribe from newsletter, giving mailjet listID and email"),
+ * category = @Translation("Simplenews Mailjet Subscriptions"),
+ * context_definitions = {
+ * "listID" = @ContextDefinition("integer",
+ * label = @Translation("Mailjet list ID"),
+ * description = @Translation("Specifies the mailjet list ID from which simplenews list will be found and email will be unsubscribed from.")
+ * ),
+ * "email" = @ContextDefinition("string",
+ * label = @Translation("Subscriber email"),
+ * description = @Translation("Specifies the email to unsubscribe.")
+ * )
+ * }
+ * )
+ */
+class UnsubscribeFromList extends RulesActionBase {
+
+ /**
+ * Deletes the Entity.
+ *
+ * @param integer listID
+ * The mailjet list to unsubcsribe from.
+ *
+ * @param string email
+ * The email to unsubcribe.
+ */
+ protected function doExecute(integer $listID, string $email) {
+ $l = $listID;
+ $e = $email;
+ \Drupal::logger('simplenews_mailjet_subscriptions')->notice(print_r($listID, true));
+ // \Drupal::logger('simplenews_mailjet_subscriptions')->notice("Unsubscribe webhook triggered for listID: " . $listID . ", and email: " . $email . ".");
+
+ // find corresponding simplenews list from mailjet listID
+
+ // get subscriber entity
+
+ // unsubscribe subscriber from simplenews list
+ }
+
+}
\ No newline at end of file
diff --git a/src/SimplenewsMailjetSubscriptionsInterface.php b/src/SimplenewsMailjetSubscriptionsInterface.php
index c727d26..37c082d 100644
--- a/src/SimplenewsMailjetSubscriptionsInterface.php
+++ b/src/SimplenewsMailjetSubscriptionsInterface.php
@@ -36,43 +36,43 @@ interface SimplenewsMailjetSubscriptionsInterface extends ConfigEntityInterface
*/
public function getId();
- /**
- * Returns the entity api key.
- *
- * @return string
- * The entity api key.
- */
- public function getApiKey();
+ // /**
+ // * Returns the entity api key.
+ // *
+ // * @return string
+ // * The entity api key.
+ // */
+ // public function getApiKey();
- /**
- * Sets the entity api key.
- *
- * @param string $api_key
- * Api key.
- *
- * @return $this
- * The Simplenews Mailjet Subscription entity.
- */
- public function setApiKey($api_key);
+ // /**
+ // * Sets the entity api key.
+ // *
+ // * @param string $api_key
+ // * Api key.
+ // *
+ // * @return $this
+ // * The Simplenews Mailjet Subscription entity.
+ // */
+ // public function setApiKey($api_key);
- /**
- * Returns the entity secret key.
- *
- * @return string
- * The entity secret key.
- */
- public function getSecretkey();
+ // /**
+ // * Returns the entity secret key.
+ // *
+ // * @return string
+ // * The entity secret key.
+ // */
+ // public function getSecretkey();
- /**
- * Sets the entity secret key.
- *
- * @param string $secret_key
- * Secret key.
- *
- * @return $this
- * The Simplenews Mailjet Subscription entity.
- */
- public function setSecretkey($secret_key);
+ // /**
+ // * Sets the entity secret key.
+ // *
+ // * @param string $secret_key
+ // * Secret key.
+ // *
+ // * @return $this
+ // * The Simplenews Mailjet Subscription entity.
+ // */
+ // public function setSecretkey($secret_key);
/**
* Sets the entity mapping table.
diff --git a/src/SimplenewsMailjetSubscriptionsMailjetHandler.php b/src/SimplenewsMailjetSubscriptionsMailjetHandler.php
new file mode 100644
index 0000000..a68cbf1
--- /dev/null
+++ b/src/SimplenewsMailjetSubscriptionsMailjetHandler.php
@@ -0,0 +1,47 @@
+<?php
+
+namespace Drupal\simplenews_mailjet_subscriptions;
+
+use Mailjet\Resources;
+use Drupal\mailjet\MailjetHandler;
+
+/**
+ * Implement SimplenewsMailjetSubscriptionsMailjetHandler interface.
+ */
+class SimplenewsMailjetSubscriptionsMailjetHandler extends MailjetHandler implements SimplenewsMailjetSubscriptionsMailjetHandlerInterface{
+
+ /**
+ * {@inheritdoc}
+ *
+ * @return array|null
+ * Return array with result or null.
+ */
+ public function createMailjetContact($email): ?array {
+
+ $response = $this->mailjetClient->post(Resources::$Contact, ["body" => ['Email' => $email]]);
+
+ if ($response->success()) {
+ return $response->getData();
+ }
+
+ return NULL;
+ }
+
+ /**
+ * {@inheritdoc}
+ *
+ * @return array|null
+ * Return array with result or null.
+ */
+ public function getMailjetContactByEmail($email): ?array {
+
+ $response = $this->mailjetClient->get(Resources::$Contact, ['id' => $email]);
+
+ if ($response->success()) {
+ return $response->getData();
+ }
+
+ return NULL;
+ }
+
+}
\ No newline at end of file
diff --git a/src/SimplenewsMailjetSubscriptionsMailjetHandlerInterface.php b/src/SimplenewsMailjetSubscriptionsMailjetHandlerInterface.php
new file mode 100644
index 0000000..b6484d7
--- /dev/null
+++ b/src/SimplenewsMailjetSubscriptionsMailjetHandlerInterface.php
@@ -0,0 +1,34 @@
+<?php
+
+namespace Drupal\simplenews_mailjet_subscriptions;
+
+use Drupal\mailjet\MailjetHandlerInterface;
+
+/**
+ * Interface for mailjet handler.
+ */
+interface SimplenewsMailjetSubscriptionsMailjetHandlerInterface extends MailjetHandlerInterface {
+
+ /**
+ * create contact.
+ *
+ * @param string $email
+ * email of the contact
+ *
+ * @return array|null
+ * Return array with the result or null.
+ */
+ public function createMailjetContact($email): ?array;
+
+ /**
+ * Get contact by email.
+ *
+ * @param string $email
+ * email of the contact
+ *
+ * @return array|null
+ * Return array with the result or null.
+ */
+ public function getMailjetContactByEmail($email): ?array;
+
+}
\ No newline at end of file
diff --git a/src/SimplenewsMailjetSubscriptionsUtilities.php b/src/SimplenewsMailjetSubscriptionsUtilities.php
index 950ff8a..5cb351d 100644
--- a/src/SimplenewsMailjetSubscriptionsUtilities.php
+++ b/src/SimplenewsMailjetSubscriptionsUtilities.php
@@ -2,141 +2,122 @@
namespace Drupal\simplenews_mailjet_subscriptions;
+// use Drupal\mailjet\MailjetHandlerInterface;
+use Drupal\simplenews_mailjet_subscriptions\SimplenewsMailjetSubscriptionsMailjetHandlerInterface;
+
/**
- * Provides a list of Simplenews Mailjet Subscription entities.
+ * Utilisties
*/
class SimplenewsMailjetSubscriptionsUtilities {
/**
- * Check Subscriber.
+ * MailjetHandler service.
+ *
+ * @var \Drupal\Simplenews_mailjet_subscriptions\SimplenewsMailjetSubscriptionsMailjetHandlerInterface
+ */
+ protected $mailjetHandler;
+
+/**
+ * SubscribeEmailForm constructor.
+ *
+ * @param \Drupal\Simplenews_mailjet_subscriptions\SimplenewsMailjetSubscriptionsMailjetHandlerInterface $mailjetHandler
+ * The mailjet handler service.
*/
- private static function checkSubscriber($api_key, $secret_key, $encoded_mail) {
-
- // Check if contact exist
- // verifica se o contacto ja tem opções.
- $endpoint = 'https://api.mailjet.com/v3/REST/contactdata/' . $encoded_mail;
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
- curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
- curl_setopt($ch, CURLOPT_USERPWD, $api_key . ':' . $secret_key);
- curl_setopt($ch, CURLOPT_URL, $endpoint);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- $response = curl_exec($ch);
- curl_close($ch);
- $json = json_decode($response, TRUE);
-
- return $json;
+ public function __construct(SimplenewsMailjetSubscriptionsMailjetHandlerInterface $mailjetHandler) {
+ $this->mailjetHandler = $mailjetHandler;
}
/**
- * Update Subscriber.
+ * {@inheritDoc}
*/
- private static function updateSubscriber($api_key, $secret_key, $listID, $subscriber_email, $contact_property, $newsletter_property_name, $action) {
-
- // Add contact to mailjet.
- $endpoint = 'https://api.mailjet.com/v3/REST/contactslist/' . $listID . '/managecontact';
- $message = [
- "Properties" => [
- $contact_property => $newsletter_property_name,
- ],
- "Action" => $action,
- "Email" => $subscriber_email,
- ];
- $payload = json_encode($message);
-
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
- curl_setopt($ch, CURLOPT_USERPWD, $api_key . ':' . $secret_key);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
- curl_setopt($ch, CURLOPT_URL, $endpoint);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- $response = curl_exec($ch);
- curl_close($ch);
- $json = json_decode($response, TRUE);
-
- return $json;
+ public static function create(ContainerInterface $container) {
+ return new static(
+ $container->get('simplenews_mailjet_subscriptions.handler')
+ );
+ }
+
+ public function checkSubscriber($encoded_mail) {
+ $response = $this->mailjetHandler->getMailjetContactByEmail($encoded_mail);
+ if ($response) {
+ // contact alredy exists
+ $contact_id = $response[0]['ID'];
+ return $contact_id;
+ }
+
+ return null;
+ }
+
+ public function createSubscriber($email) {
+ $response = $this->mailjetHandler->createMailjetContact($email);
+ if ($response) {
+ // contact alredy exists
+ $contact_id = $response[0]['ID'];
+ return $contact_id;
+ }
+
+ return null;
}
/**
* Subscribe User.
*/
- public static function subscribeUser($subscriber, $subscription, $category, $api_key, $secret_key, $listID) {
+ public function subscribeUser($listID, $subscriber, $category) {
- $contact_property = $category['contact_property'];
- $newsletter_property_name = $category['newsletter_property_name'];
$subscriber_email = $subscriber->getMail();
- $encoded_mail = urlencode($subscriber_email);
- $response = '';
- $contact_info = self::checkSubscriber($api_key, $secret_key, $encoded_mail);
+ // hook is sometimes called with empty subscriber
+ if (!$subscriber_email) return;
- $options = $contact_info['Data'];
+ $encoded_mail = urlencode($subscriber_email);
- // Se existe - acrescenta a opções.
- if ($options[0]['Data']) {
- foreach ($options[0]['Data'] as $property) {
- if ($property["Name"] == $contact_property) {
+ $contactid = $this->checkSubscriber($encoded_mail);
+ if (!$contactid) {
+ // subscriber does not exists yet, create it
+ $contactid = $this->createSubscriber($subscriber_email);
+ }
- if (is_int(strpos($property['Value'], $newsletter_property_name))) {
- $newsletter_property_name = $property['Value'];
- }
- else {
- $newsletter_property_name = $property['Value'] . ';' . $newsletter_property_name;
- }
- }
+ if ($contactid) {
+ $contact = [
+ 'Email' => $subscriber_email,
+ // 'Properties' => [
+ // $contact_property => $newsletter_property_name
+ // ]
+ ];
+
+ $response = $this->mailjetHandler->syncMailjetContact($listID, $contact, 'addnoforce');
+ if ($response) {
+ // $contact_id = $response['Data'][0]['ContactID'];
+ \Drupal::logger('simplenews_mailjet_subscriptions')->notice('The mailjet user ' . $subscriber_email . ' subscribed to the ' . $listID . ' list.');
+ }else{
+ \Drupal::logger('simplenews_mailjet_subscriptions')->warning('error while subscrining ' . $subscriber_email . ' to the ' . $listID . ' list.');
}
+
+ } else {
+ \Drupal::logger('simplenews_mailjet_subscriptions')->warning($subscriber_email . ' does not exists and can not be created on mailjet.');
}
- $response = self::updateSubscriber($api_key, $secret_key, $listID, $subscriber_email, $contact_property, $newsletter_property_name, 'addnoforce');
- $contact_id = $response['Data'][0]['ContactID'];
- \Drupal::logger('simplenews_mailjet_subscriptions')->notice('The mailjet user ' . $contact_id . ' subscribed to the ' . $contact_property . ' properties with the ' . $newsletter_property_name . ' values in the list ' . $listID . '.');
- return $response;
+
}
/**
* Unsubscribe User.
*/
- public static function unsubscribeUser($subscriber, $subscription, $category, $api_key, $secret_key, $listID) {
- $contact_property = $category['contact_property'];
- $newsletter_property_name = $category['newsletter_property_name'];
+ public function unsubscribeUser($listID, $subscriber, $category) {
$subscriber_email = $subscriber->getMail();
- $encoded_mail = urlencode($subscriber_email);
- $response = '';
-
- $contact_info = self::checkSubscriber($api_key, $secret_key, $encoded_mail);
- $contact_id = $contact_info['ContactID'];
- $options = $contact_info['Data'];
-
- if ($options[0]['Data']) {
- foreach ($options[0]['Data'] as $property) {
- if ($property["Name"] == $contact_property) {
- if (substr_count($property['Value'], ';') == 0) {
- $newsletter_property_name = '';
- $response = self::updateSubscriber($api_key, $secret_key, $listID, $subscriber_email, $contact_property, $newsletter_property_name, 'remove');
- $contact_id = $response['Data'][0]['ContactID'];
- \Drupal::logger('simplenews_mailjet_subscriptions')->notice('The mailjet user ' . $contact_id . ' unsubscribed to the list ' . $listID . '.');
- }
- else {
- $pos = strpos($property['Value'], $newsletter_property_name);
- \Drupal::logger('simplenews_mailjet_subscriptions')->notice('The mailjet user ' . $contact_id . ' unsubscribed to the ' . $contact_property . ' properties with the ' . $newsletter_property_name . ' values in the list ' . $listID . '.');
- if ($pos === 0) {
- $newsletter_property_name = str_replace($newsletter_property_name . ';', '', $property['Value']);
- }
- else {
- $newsletter_property_name = str_replace(';' . $newsletter_property_name, '', $property['Value']);
- }
- $response = self::updateSubscriber($api_key, $secret_key, $listID, $subscriber_email, $contact_property, $newsletter_property_name, 'addnoforce');
- $contact_id = $response['Data'][0]['ContactID'];
- \Drupal::logger('simplenews_mailjet_subscriptions')->notice('The mailjet user ' . $contact_id . 'remains subscribed to the ' . $contact_property . ' properties with the ' . $newsletter_property_name . ' values in the list ' . $listID . '.');
-
- }
- }
- }
- }
+ $contact = [
+ 'Email' => $subscriber_email,
+ // 'Properties' => [
+ // $contact_property => $newsletter_property_name
+ // ]
+ ];
- return $response;
+ $response = $this->mailjetHandler->syncMailjetContact($listID, $contact, 'remove');
+ if ($response) {
+ // $contact_id = $response['Data'][0]['ContactID'];
+ \Drupal::logger('simplenews_mailjet_subscriptions')->notice('The mailjet user ' . $subscriber_email . ' removed from the ' . $listID . ' list.');
+ }else{
+ \Drupal::logger('simplenews_mailjet_subscriptions')->warning('error while removing ' . $subscriber_email . ' from the ' . $listID . ' list.');
+ }
}
}

View File

@@ -61,7 +61,7 @@ class MaterioFlagActionsController extends ActionLinkController {
// $nid = $node->id();
// call the parent flag function
$this->flag($flag, $id, $flagcollid);
$this->flag($flag, $id, 'default', $flagcollid);
// // OR rewrite it entirely
// $entity = $this->flagService->getFlaggableById($flag, $nid);
@@ -104,7 +104,7 @@ class MaterioFlagActionsController extends ActionLinkController {
// $node = \Drupal::service('entity.repository')->loadEntityByUuid('node', $uuid);
// $nid = $node->id();
// call the parent flag function
$this->unflag($flag, $id, $flagcollid);
$this->unflag($flag, $id, 'default', $flagcollid);
// response
$data = [
'flag' => $flag->toArray(),

View File

@@ -730,6 +730,8 @@ $settings['container_yamls'][] = $app_root . '/' . $site_path . '/services.yml';
* Provide a fully qualified class name here if you would like to provide an
* alternate implementation YAML parser. The class must implement the
* \Drupal\Component\Serialization\SerializationInterface interface.
*
* This setting is deprecated in Drupal 10.3 and removed in Drupal 11.
*/
# $settings['yaml_parser_class'] = NULL;