0

I have a dxp_installer installation profile. I want to use the container injection for a service which I use in hook_install_tasks_alter() to verify the installation requirements. Note that I inject this service in one of my custom install forms construct, and not directly from the dxp_installer.install file.

I have defined this service in the dxp_installer.services.yml file. Now when I add container->get('dxp_installer.service'), I get an error about calling a non-existent service. Note that Drupal isn't installed yet at this stage. Are service files only usable after Drupal is installed?

Meanwhile, the actual service class is accessible with $service = new InstallerService(), which means the class is reachable by the class loader.

6
  • 1
    Can you confirm that hook name? Drupal doesn't seem to have a hook_install_alter. This is the standard reminder that Drupal 8 reached end-of-life on November 2, 2021 and has known security bugs.
    – cilefen
    May 1 at 17:34
  • Thanks for the response, Cilefen. I meant to write hook_install_tasks_alter. I have made the correction in the original question. I'm also actually running this on Drupal 10, I've also updated the tags. So then are service.yml files allowed in Installation Profiles?
    – ilechcod
    May 1 at 22:08
  • 1
    It's so early in the process you may have the minimal container. What services are in the container at that stage?
    – cilefen
    May 1 at 22:33
  • This isn't even a Drupal-defined service that I'm trying to access here. I'm trying to access a custom service which I defined in my profile's service.yml file. The question rather should be whether that service.yml file is processed at all - at that early stage?
    – ilechcod
    May 2 at 10:08
  • Seems like I have to look for another way to reach my service then. Just wished container injection was available - it's a cleaner approach.
    – ilechcod
    May 4 at 20:06

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.