Make auto-detection of the current module path to simplify arguments for some functions

Created on 9 March 2023, over 1 year ago

Problem/Motivation

In some API functions we should pass a path to a module file, like in callEventSubscriber() or createServiceFromYaml().

I will try to simplify the things using some tricks to autodetect the module location path.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Fixed

Version

1.0

Component

Code

Created by

🇦🇲Armenia murz Yerevan, Armenia

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @murz
  • @murz opened merge request.
  • Status changed to Fixed over 1 year ago
  • 🇦🇲Armenia murz Yerevan, Armenia

    I've added new helper functions, that try to autodetect module names and paths:

    • getModuleName() - Gets a module name from a namespace of a module class.
    • getModuleRoot() - Gets a root module folder from a module file full path.

    And a new function initService that initializes a service only by the class name, or a service name.

    And I had to make a breaking change in the function callEventSubscriber() to accept only the service name as the first parameter, so the list of parameters is changed from this:
    function callEventSubscriber(string $servicesYamlFile, string $serviceName, string $eventName, &$event): void;
    to this:
    function callEventSubscriber($service, string $eventName, object &$event): void;

    To have the previous behavior, now you need to pass the service YAML file and the service name in the first parameter as an array.

    • Murz committed bba75ef8 on 1.0.x
      Issue #3346933 by Murz: Make auto-detection of the current module path...
  • Status changed to Fixed over 1 year ago
  • 🇦🇲Armenia murz Yerevan, Armenia
  • @murz opened merge request.
Production build 0.71.5 2024