Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contact Token replacer #6710

Open
wants to merge 65 commits into
base: staging
from

Conversation

Projects
8 participants
@kuzmany
Copy link
Contributor

kuzmany commented Oct 10, 2018

Please be sure you are submitting this against the staging branch.

Q A
Bug fix?
New feature?
Automated tests included?
Related user documentation PR URL
Related developer documentation PR URL
Issues addressed (#s or URLs)
BC breaks?
Deprecations?

Description:

Based on this discussion #6237 (comment)
This PR replace TokenHelper ::findLeadTokens static method to service easy to use for developers.

Contains:

DateTimeHelper localization support

  • DateTime - doesn't support localizated months/days

Docs: To format dates in other languages, you should use the setlocale() and strftime() functions instead of date() http://php.net/manual/en/function.date.php

But strftime doesn't support date before Jan 1, 1970 on some OS

This means that %e, %T, %R and, %D (and possibly others) - as well as dates prior to Jan 1, 1970 - will not work on Windows, some Linux distributions, and a few other operating systems. http://php.net/manual/en/function.strftime.php

I decide use DateTimeHelper as service with translations. All DateTime classes loaded before works properly. Just If you want use getString (https://github.com/mautic/mautic/pull/6710/files#diff-36ed844b46ee77f22d7c9a23897b4053R196) You have to use DateTimeHelper as symfony service https://github.com/mautic/mautic/pull/6710/files#diff-b675f853d4cec144df96948057f29a34R88

Another feature - relative and anniversary date modifier

This require this PR #7228
This feature allow add generate relative or anniversary date to contact date

Usage

Relative date - will generate relative date to date stored in custom contact date field

  • {contactfield=custom_date|datetime +7 days}
  • {contactfield=custom_date|date +7 days}

Anniversary date - will generate anniversary date to date stored in custom contact date field. This is helpful If you want generate birthday coupon expired date (Hi, this is your birthday discount and it will expire in {contactfield=custom_date|datetime anniversary +7 days})

  • {contactfield=custom_date|date anniversary +7 days}

  • {contactfield=custom_date|datetime anniversary +7 days}

  • tests included

Examples in screenshots are for date 2018-01-02

image

image

Steps to test this PR:

  1. Just test all channels use leadfield and contactfield tokens
  • {leadfield=email}
  • {contactfield=email}

Use also tokens with modifier

  • {leadfield=email|true} - expect url encode result
  • empty country field: {contactfield=country} - expect empty space
  • empty country field: {contactfield=country|mydefaulttext} - expect mydefaultext
  • date field: {contactfield=mycustomdatefield|date} - expect formatted date
  • date field: {contactfield=mycustomdatefield|time} - expect formatted time
  • date field: {contactfield=mycustomdatefield|datetime} - expect formatted datetime
  • relative date field: {contactfield=mycustomdatefield|datetime +1 day} - expect formatted datetime + 1 day
  • relative date field: {contactfield=mycustomdatefield|datetime anniversary +1 day} - expect formatted datetime + 1 day with current year
  • try also load {contactfield=mycustomdatefield|date} on different localization of Mautic like english (french with translated messages.ini -should do it manually) with translated months/days (https://github.com/mautic/mautic/pull/6710/files#diff-e9975204439d1e820ce16d15658d4d48R554)

Channels:

Email
SMS
DynamicContent
Focus
Notification
Campaign action Send a Webhook
Social - twitter send tweet
Page Redirect after form send

List deprecations along with the new alternative:

  1. TokenHelper marked as deprecation and replace in all bundles and plugins with new service

kuzmany added some commits Oct 11, 2018

Comments
Move stuff to abstract class

@kuzmany kuzmany changed the title Token replacer Contact Token replacer Oct 11, 2018

kuzmany added some commits Oct 11, 2018

@kuzmany kuzmany added Ready To Test and removed WIP labels Oct 11, 2018

@kuzmany kuzmany added this to the 2.14.2 milestone Oct 11, 2018

kuzmany added some commits Oct 11, 2018

@escopecz
Copy link
Member

escopecz left a comment

Wow! Looks great! Noticed a couple of minor issues.

Show resolved Hide resolved app/bundles/CoreBundle/Token/TokenAttribute.php Outdated
Show resolved Hide resolved app/bundles/CoreBundle/Token/TokenAttribute.php Outdated
Show resolved Hide resolved app/bundles/CoreBundle/Token/TokenAttribute.php Outdated
Show resolved Hide resolved app/bundles/CoreBundle/Token/TokenAttribute.php Outdated
Show resolved Hide resolved app/bundles/CoreBundle/Token/TokenReplacer.php Outdated
Show resolved Hide resolved app/bundles/LeadBundle/Tests/Token/ContactTokenReplacerTest.php Outdated
Show resolved Hide resolved app/bundles/LeadBundle/Token/ContactTokenReplacer.php Outdated
Show resolved Hide resolved app/bundles/LeadBundle/Token/ContactTokenReplacer.php Outdated
Show resolved Hide resolved app/bundles/LeadBundle/Token/ContactTokenReplacer.php Outdated
Show resolved Hide resolved app/bundles/LeadBundle/Token/ContactTokenReplacer.php Outdated

@escopecz escopecz added this to Pending Feedback in Testing 2.14.2 Oct 11, 2018

kuzmany added some commits Oct 11, 2018

clean comments
replace leads with options

@escopecz escopecz moved this from Pending Feedback to To Do in Testing 2.14.2 Oct 11, 2018

@escopecz escopecz self-assigned this Oct 11, 2018

kuzmany added some commits Oct 11, 2018

Some fixes
Change regex

kuzmany added some commits Feb 10, 2019

kuzmany added some commits Feb 11, 2019

Revert "Merge branch 'token-helper-replace' into support-language-seg…
…ment-anniversary-filter"

This reverts commit 20237fc, reversing
changes made to 159c226.

@kuzmany kuzmany requested a review from escopecz Mar 7, 2019

Mautic 2 automation moved this from Ready to Test (first time) to Changes Requested / Review Mar 7, 2019

@escopecz
Copy link
Member

escopecz left a comment

Looks good! I found some mostly CS issues.

escopecz and others added some commits Mar 7, 2019

Update app/bundles/CoreBundle/Helper/DateRelativeParser.php
Co-Authored-By: kuzmany <zdeno@kuzmany.biz>
Update app/bundles/CoreBundle/Helper/DateRelativeParser.php
Co-Authored-By: kuzmany <zdeno@kuzmany.biz>
Update app/bundles/LeadBundle/Segment/Decorator/DateDecorator.php
Co-Authored-By: kuzmany <zdeno@kuzmany.biz>

@kuzmany kuzmany requested a review from escopecz Mar 8, 2019

kuzmany added some commits Mar 9, 2019

Revert "Revert "Merge branch 'token-helper-replace' into support-lang…
…uage-segment-anniversary-filter""

This reverts commit d46594a.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.