Get Plugin Definition methods using dependency injection It is my first time defining a custom Plugin Type.
I think that this might be a comming thing in Drupal but I was not able to find any documentation anywhere.

I want to get Plugin definition methods from controller.

I use this code to get plugin definitions:

$type = \Drupal::service('plugin.manager.task');
$plugin_definitions = $type-&gt;getDefinitions();


And that gives me an array of all definitions with Plugin id, class and name.

What I want is to get methods from the definition class.

I don't know if I should create a service for every Plugin definition, but that doesn't seem to be a good idea.

Does Drupal Core have any tools to do this?

Hope that you understand.
Create an instance and then use a method on the plugin instance, for example to execute the task, if you have such a method in the plugin class:

$task = \Drupal::service('plugin.manager.task')-&gt;createInstance('my_task');

$task-&gt;execute();