Score:0

issue in construct function for dependency injection

pl flag

error I am getting : CreateApplicationService::__construct(), 0 passed in C:\xampp\htdocs\drupalwebsite\core\lib\Drupal\Component\DependencyInjection\Container.php on line 262 and exactly 1 expected

I have this below code:

enter image description here

nots sure what is the issue in the construct function. I have done the same POC in another module where I called from form.php and it works. Not sure what I am missing here?

Imti avatar
pl flag
this below is the routing which i have defined: services: OAuthTokenManagement.oauthtokenService: class: Drupal\OAuthTokenManagement\Service\OAuthTokenService
Kevin avatar
in flag
You aren't passing the argument(s) in your services.yml file. Also, your class does not implement the proper interface so that (alternatively) `create` would be called when instantiated (ContainerInjectionInterface).
Imti avatar
pl flag
@kevin : could you please elaborate more , which services.yml is missing the arguments ? and how we can add. do i have to add , is this you were referring to class CreateApplicationService extends ContainerInjectionInterface
Imti avatar
pl flag
I just added and it worked ApplicationCRUD_POC.createApplication: class: Drupal\ApplicationCRUD_POC\Service\CreateApplicationService arguments: ['@OAuthTokenManagement.oauthtokenService']
apaderno avatar
us flag
Welcome to Drupal Answers! Please, don't post code screenshots. Instead, copy the code in the question body and format it as code.
Score:1
pl flag

it was only missing argument parameter in service.yml.

I only added arguments: ['@OAuthTokenManagement.oauthtokenService']

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.