What is the best way to find right service for dependency injection? Googling is not efficient yet. For example I spent quite long time figuring out that if I need current request passed to constructor by DI I have too use:
$container->get('request_stack')->getCurrentRequest()
Full code example:
/** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { return new static( $configuration, $plugin_id, $plugin_definition, $container->getParameter('serializer.formats'), $container->get('logger.factory')->get('job_market'), $container->get('current_user'), $container->get('request_stack')->getCurrentRequest() ); }
And I’ve found above example in drupal class Documentation
Before that I’ve just found this services list but there is no description, no examples, nothing. Just a list with possibility to search.
How do you search for right service provider?