Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-9316

Provide more context to hook_civicrm_tokenValues

    Details

    • Type: Improvement
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: 3.4.7, 4.0.7
    • Fix Version/s: Unscheduled
    • Component/s: CiviMail, Core CiviCRM
    • Labels:
      None
    • Documentation Required?:
      None
    • Funding Source:
      Needs Funding

      Description

      There are cases where it would be useful to let hook_civicrm_tokenValues() know more about the context in which it's called – for example, for which mailing the tokens will be used, or for which label.

      I had thought merely to pass the mailing job ID (which the code is already attempting to do in one place), but Lobo suggested on IRC that it's even better to pass the whole mailing object or other object, in an effort to provide as much context as possible.

      This patch attempts to do that.

      In cases where the hook is called from a static method, a relevant object from the context is passed instead. Where a non-static method is called statically, the object passed is obviously NULL, but in that case there's not a lot of context for the hook implementation to use anyway.

        Attachments

        1. tokenValues-3.4.patch
          4 kB
          Allen Shaw
        2. tokenValues-4.1.patch
          5 kB
          Allen Shaw

          Activity

            People

            • Assignee:
              allenshaw Allen Shaw
              Reporter:
              allenshaw Allen Shaw
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: