8 – Accessing a contrib module’s code that has no service

I am doing custom work on a drupal site that uses particular installation profile. And the profile comes with a huge module that does a lot of work. Some of the classes I’ve been able to inject into my code.

I understand that interfaces aren’t supposed to work this way, but it seems like, inside the module, the interface is passed as a parameter into a class’s method and is assigned to a variable and that variable is an object. And from that an object is formed. I know I’m missing something here, I just don’t know what.

This is an example of the code in the module:

public function userResult(OpignoModuleInterface $opigno_module) {         
$step_info = opigno_learning_path_get_module_step($gid, $uid, 
$opigno_module, $latest_cert_date);       
$current_step_key = array_search($opigno_module->id(), array_column($steps, 'id')); 

If I run it through Xdebug, $opingo_module is an object. It appears to me that OpignoModuleInterface is assign to $opigno_module. But I’m new to this. It becomes an object. And I really want that object for the custom code I’m creating.

So, this is how I configured my service:

    class: Drupalptc_after_course_redirectRouteListener
    arguments: ('')
      - { name: event_subscriber }

And then I passed the OpignoModuleInterface into the class’s method just as they had. It didn’t work, because there’s no service associated with it. As you can see, the argument in the yaml file is empty. Nothing to put there.

Per @Clive, it does seem like an entity. Clive recommended this: $this->entityTypeManager->getStorage('opigno_module')->load($id);

But it comes back null.