Dont include services for formatters when its dependencies are not met
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3332475. --> Reported by: [dpi](https://www.drupal.org/user/81431) Related to !13 >>> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>The <a href="https://www.drupal.org/project/phpstorm_metadata">PHPStorm metadata</a> project iterates through all services and instantiates each one. Probably to a fault. However I think it uncovered an issue that should be resolved.</p> <p>When you try to grab an instance of <code>monolog.formatter.gelf</code>, where the dependency is not instealled, the contructor throws an exception.</p> <p>I think services shouldnt be created if their dependencies are not met, or cannot operate with optional dependencies.</p> <h4 id="summary-steps-reproduce">Steps to reproduce</h4> <p>Configure this project until success.<br> Require and install PHPStorm metadata project (module).<br> Ensure graylog2/gelf-php is not installed.<br> Run <code>drush phpstorm-metadata:generate</code><br> Notice an exception is caught: "An error occurred during file generation:". Note, exception message is currently bugged.</p> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <p>Use a service provider, compiler pass, or whatever other relevant Symfony functionality, to optionally add the service.</p> <h3 id="summary-remaining-tasks">Remaining tasks</h3> <p>Decide, implement.</p> <h3 id="summary-ui-changes">User interface changes</h3> <p>None.</p> <h3 id="summary-api-changes">API changes</h3> <p>Service with required dependencies may not be present.</p> <h3 id="summary-data-model-changes">Data model changes</h3> <p>Nil</p>
issue