Dont include services for formatters when its dependencies are not met

Created on 10 January 2023, over 1 year ago
Updated 26 October 2023, 8 months ago

Problem/Motivation

The PHPStorm metadata project iterates through all services and instantiates each one. Probably to a fault. However I think it uncovered an issue that should be resolved.

When you try to grab an instance of monolog.formatter.gelf, where the dependency is not instealled, the contructor throws an exception.

I think services shouldnt be created if their dependencies are not met, or cannot operate with optional dependencies.

Steps to reproduce

Configure this project until success.
Require and install PHPStorm metadata project (module).
Ensure graylog2/gelf-php is not installed.
Run drush phpstorm-metadata:generate
Notice an exception is caught: "An error occurred during file generation:". Note, exception message is currently bugged.

Proposed resolution

Use a service provider, compiler pass, or whatever other relevant Symfony functionality, to optionally add the service.

Remaining tasks

Decide, implement.

User interface changes

None.

API changes

Service with required dependencies may not be present.

Data model changes

Nil

🐛 Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

🇦🇺Australia dpi Perth, Australia

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024