After some time spent developing Orchard modules I found many useful, yet not documented extension points you can use when writing your own Orchard-based apps. Mentions of many of them are scattered throughout the Orchard discussion board so I made an effort to put them all in one place.
Although in most cases you won’t use all of those features in a single app, knowledge of what you can do can be useful when building more complex, custom, Orchard-based applications.
Note: As far as I have seen the naming convention states that interfaces ending with “Service” are single instance, so if you create the custom implementation, it will be the one used across the whole app. In contrast, interfaces ending with “Provider” mark objects that are thought to provide additional functionality and cooperate with other existing ones, so to be used and injected as an IEnumerable<ISomeProvider>.
Authentication and authorization
- IAuthenticationService – responsible for user authentication in Orchard. By default, orchard uses forms-based authentication delivered by FormsAuthenticationService. Custom implementation overrides the default one.
- IAuthorizationService – responsible for user authorization in Orchard. By default, Orchard uses role-based authorization delivered by Orchard.Roles module. Custom implementation overrides the default RolesBasedAuthorizationService.
- IMembershipService – responsible for account creation and retrieval. The default MembershipService comes from Orchard.Users.
- IPermissionsProvider – allows creating custom permissions for reuse in authorization service. Check the Orchard.Blogs permissions provider as an example.
- INavigationProvider – provides additional menu items to be merged into the named menu. Implementations can be found almost in every module, which adds menu items to the Dashboard (e.g.. in Orchard.Blogs).
- IMessagingChannel – defines a channel for sending messages from Orchard. Orchard.Email defines the only one – “email” messaging channel, but you are free to create your own. After creating a custom channel you’d be able to force Orchard to use it by default by choosing it as a default one in Site settings.
- FilterProvider – defines the filter applied to each request. Resembles the way default ASP.NET MVC action filters work with the difference that it’s not an attribute. All FilterProvider objects are injected into the request pipeline and are applied to all requests (so you need to check if the current request is suitable for your filter at the beginning of an appropriate method).
- As with the default ASP.NET MVC filters, your filter also has to implement one (or more) of the following interfaces: IActionFilter, IAuthorizationFilter, IResultFilter, IExceptionFilter. Check those as an example: AdminFilter, ThemeFilter, SecurityFilter.
- IShapeTableProvider – allows you to programmatically describe your own shapes. Shapes from shape table providers are merged with the dynamically discovered ones (from .cshtml files). Check the CoreShapes definition as an example.
- IBackgroundTask – defines the task, which will be run in the background in specified time intervals. It’s Sweep() method will be called every 1 minute (hardcoded in Orchard.Tasks.SweepGenerator). Chris Bower wrote a nice article about that.
- IScheduledTask – defines the task, which will be run once at a specified time. You can create new tasks via IScheduledTaskManager – just inject this as a dependency and use inside your task-creating objects.
- IScheduledTaskHandler – defines the processing logic for your custom defined scheduled tasks (look at Orchard.PublishLater module for example).
- IRepository<T> – defines the interface for data storage. By default Orchard uses NHibernate to store items in the DB, but you are free to define your own storage logic for specific items. Just implement this interface for the object type you'd like to store an it will override the default one.
Orchard delivers a lot more extension points you can make use of. I tried to describe the ones I found the most useful. If you found some other useful ones not described here, fell free to post the info about them in comments – I’ll update the list above.
If the list becomes full enough – I’ll make an effort to place it in the official documentation