Using services from one module from another module

Nov 15, 2010 at 3:05 PM

What is the guideline/API for using another module from my module? Since modules are loosely attached I guess they shouldn't be referenced directly. Could you please point me to a simple example on the source where a module reuses another module?

I'm trying to create a field that uses the Media feature to upload a file.



Nov 15, 2010 at 3:12 PM

Generally, transversal concepts have their interfaces in Core, and are implemented as separate modules, which provides implementation independence. A good example is user management which is handled through the IUser interface, and thus you don't need to reference Orchard.Users from other modules. But in case the concept is not handle by Core or Framework, then you have no choice but to define a Module.txt dependency, and also a binary one. Though go can go further by create three modules:
- One containing some interfaces
- Your module dependant on those interfaces
- A specific implementation of those interfaces, which has a dependency on some others if needed

Your services to check if implementations are activated, or display a message if not. Orchard.Messaging is doing it if no Channel is active, also does the Indexing service if Lucene is not enabled.