asp.net-mvcorchardcmsorchardcms-1.8

Override Orchard Setup view in Orchard CMS


I need to extend SetupViewModel from Orchard.Setup module to add some options specific for my web application so that they to be shown on "Welcome to Orchard" setup screen alongside with the standard admin user name and so on. I've create my own module with SetupController and extended view model, but Orchard still uses standard Orchard.Setup module. What I tried so far but have no luck: 1. OrchardSuppressDependency on Controller in my custom module 2. Route with the priority 101 in my custom module I've find out that you can easily use own module for Setup if you change ShallFeature name in ShellContextFactory CreateSetupContext method:

public ShellContext CreateSetupContext(ShellSettings settings) {
        Logger.Debug("No shell settings available. Creating shell context for setup");

        var descriptor = new ShellDescriptor {
            SerialNumber = -1,
            Features = new[] {
                new ShellFeature { Name = "YOUR_MODULE_NAME" },
                new ShellFeature { Name = "Shapes" },
                new ShellFeature { Name = "Orchard.jQuery" },
            },
        };

        var blueprint = _compositionStrategy.Compose(settings, descriptor);
        var shellScope = _shellContainerFactory.CreateContainer(settings, blueprint);

        return new ShellContext {
            Settings = settings,
            Descriptor = descriptor,
            Blueprint = blueprint,
            LifetimeScope = shellScope,
            Shell = shellScope.Resolve<IOrchardShell>(),
        };
    }

But it seems that I can't override IShellContextFactory even with OrchardSuppressDependency at least for Setup purposes.

Any idea on how I can achieve the desired result without changing CMS code?

Orchard version is 1.8.1.


Solution

  • So, it's not a completely what I was trying to achive, but it is something. To override IShellContextFactory that is used during Orachard setup process, you can use Host.config file. Example:

       <autofac>
            <components>
                <component instance-scope="single-instance" type="YourModuleNamespace.ShellBuilders.CustomContextFactory, YourModuleName" service="Orchard.Environment.ShellBuilders.IShellContextFactory, Orchard.Framework" />
            </components>
       </autofac>
    

    At least you don't have to change Orchard sources.