Score:0

How can I identify the service ID?

ni flag

I am trying to use Cdn service provided in CDN module version 4.0.1 in my custom module Until 3.x version we had service id as cdn.settings

But from 4.x version I can see there is no service id

https://git.drupalcode.org/project/cdn/-/blob/4.x/cdn.services.yml?ref_type=heads

I need to pass cdn.settings service id as an argument in my custom service but I am not able to pass due to missing service id as shown below , when I pass cdn.settings in argument it gives an error, what should be the solution for the same ?

    class: 'Drupal\abc_views\CDNWrapperService'
    arguments: ["@cdn.settings", "@request_stack"]```

Score:2
cn flag

These are the first two entries in the services file you have linked:

services:
  Drupal\cdn\CdnSettings:
    arguments: ['@config.factory']

  Drupal\cdn\File\FileUrlGenerator:
    public: false
    decorates: file_url_generator
    arguments:
      - '@Drupal\cdn\File\FileUrlGenerator.inner'
      - '%app.root%'
      - '@stream_wrapper_manager'
      - '@request_stack'
      - '@private_key'
      - '@Drupal\cdn\CdnSettings'

You can see in the second service definition that the last argument is referencing the first service.

Using the class name as service ID makes it easier to autowire services, although Drupal didn't take this route for core services, they implemented aliases. See https://www.drupal.org/node/3323122

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.