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

Separate "container" and "compiler pass" hooks

    Details

    • Type: Patch
    • Status: Won't Do
    • Priority: Important
    • Resolution: Won't Do
    • Affects Version/s: 4.7.21
    • Fix Version/s: None
    • Component/s: Core CiviCRM
    • Labels:
    • Versioning Impact:
      Minor (add functionality in backwards-compatible manner)
    • Documentation Required?:
      Developer Doc
    • Funding Source:
      Contributed Code
    • Verified?:
      No
    • How it works currently:
      Only a single hook is available for working with container definitions.
    • How it should work:
      Two hooks should be available, one for registration of services, the other for working with tagged services.
    • Acceptance Criteria:
      The new hook is fired and is called in extensions.

      Description

      The "container" hook allows extensions to register services and parameters in the container.

      In Symfony container operations are separated into registration (which is usually done with configuration files like services.yml and parameters.yml) and compilation (which is done with compiler passes).

      The most common reason for this is working with tagged services. For example, suppose I create an extension called "super_api" with a service called "api_provider". This provider has a method to register new "api" services, so before the container is compiled I will search for all services tagged "api". If I only have the "container" hook available then I'll do it there.

      Now another extension called "visa_extension" adds a "visa_api" service and tags it with "api". However, the order that extension hooks are called is not defined. I cannot be sure that this service will be visible to my "container" hook, it depends which hook is called first; if visa_extension_civicrm_container is called first everything is fine, but if it's the other way around then we'll have one frustrated extension developer.

      I suggest adding another hook, "civicrm_containerCompilerPass". The signature would be exactly the same as "civicrm_container" and it would be called right afterwards. The only difference is that we ensure the documentation shows that if you want to do something with tagged services you should use "civicrm_containerCompilerPass".

        Attachments

          Activity

            People

            • Assignee:
              michael Michael Devery
              Reporter:
              michael Michael Devery
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: