magento / community-features

Magento Features Development is an Initiative to Allows Community Memebers Join to Development of Magento Features
46 stars 18 forks source link

Allow optional constructor dependencies #39

Closed navarr closed 3 years ago

navarr commented 6 years ago

If a constructor asks for an object of a class type and has a default value of NULL, provide NULL instead of throwing an exception if the class type cannot be provided.

This would allow extensions that can support Commerce features to use Dependency Injection for Commerce classes ("or NULL") without having to use ObjectManager directly

orlangur commented 6 years ago

Can such dependencies be specified via di.xml currently so that a module would have soft dependency on Commerce module?

sivaschenko commented 3 years ago

I think references to classes that do not exist in the project should lead to an exception being thrown.

I my opinion the best approach is to deliver Commerce edition related functionality in a separate module installed only for Commerce edition. This should also ensure the correct dependency between modules (and versioning i.e. when using composer).