2017-04-10 67 views
1

我需要從Orchard.Setup模塊擴展SetupViewModel添加一些特定於我的Web應用程序選項,以便在「歡迎來到果園」設置屏幕中顯示與旁邊標準的管理員用戶名,他們等等。 我用SetupController和擴展視圖模型創建了自己的模塊,但Orchard仍然使用標準的Orchard.Setup模塊。 我到目前爲止的嘗試,但沒有運氣: 1.我的自定義模塊中的OrchardSuppress控制器的依賴關係 2.我的自定義模塊中的優先級101的路由 我發現,如果您使用自己的模塊在ShellContextFactory CreateSetupContext方法改變ShallFeature名稱:覆蓋果園安裝鑑於烏節CMS

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>(), 
     }; 
    } 

但似乎我不能重寫IShellContextFactory甚至OrchardSuppressDependency安裝程序的目的至少。

我如何能實現在不改變CMS代碼所期望的結果你知道嗎?

果園版本是1.8.1。

回答

0

所以,這不是一個完全我試圖才達到,但它是什麼。要覆蓋Orachard安裝過程中使用的IShellContextFactory,可以使用Host.config文件。 例如:

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

至少您不必更改果園來源。