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

          [CRM-9316] Provide more context to hook_civicrm_tokenValues
          Coleman Watts added a comment -

          Allen Shaw should we keep this issue open? I see there has been some evolution of this hook since you originally submitted these patches, but maybe there's more you want to do?

          Allen Shaw added a comment -

          I think these patches did all that I was trying to do, back when they were submitted. I haven't looked at this issue since then. Is there more that needs to be done to get this functionality?

          Coleman Watts added a comment -

          Looking at your patches and the current state of things I'm a little concerned about breaking changes to hook function signatures. Adding a new param at the end seems like it might be safer than changing an existing param. Interested in submitting a pull-request?

          Allen Shaw added a comment -

          Right, changing hook signatures is bad

          Providing more context to this hook would be great, but not I'm sure if I have time to pursue this any further, so I'll just close it now. Maybe another time or place.

          Allen Shaw added a comment -

          "Won't fix" for the foreseeable future, but not because we're inherently opposed to the idea.

            People

            • Assignee:
              Allen Shaw
              Reporter:
              Allen Shaw

              Dates

              • Created:
                Updated:
                Resolved: