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

Move CiviCRM initialization out of service constructor (in Drupal 8) and into method

    Details

    • Versioning Impact:
      Major (incompatible API change)
    • Documentation Required?:
      Developer Doc
    • Funding Source:
      Needs Funding
    • Verified?:
      No

      Description

      Currently, the way to initialize CiviCRM is to construct the service via:

      \Drupal::service('civicrm');
      

      However, service constructors really, traditionally shouldn't have any side-effects - the constructor should just get the object ready to be used. Since a service might need to be constructed just to resolve a dependency, it doesn't necessarily mean any work is actually about to be done with the service.

      Instead, I think this should be:

      \Drupal::service('civicrm')->initialize();
      

      That way you have to explicitly call a method to cause all the side-effects that is initializing CiviCRM.

      This is an API change, but since the Drupal 8 integration module isn't officially released, I think now is the time to make it!

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              dsnopek David Snopek
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: