-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ShellDescriptorManager depends on YesSql.ISession and isn't ideal when only using OrchardCore without the CMS #10311
Comments
//cc @jtkech Seems like it already works by using the DI so I'm not sure if it's necessary. Should we consider this for other reasons? |
@Skrypt I don't really want to maintain a separate copy of the Also, since |
I'm not sure, but I think it will also require to remove entirely YesSQL from OrchardCore.Infrastructure. |
I am not asking that we remove the entire OrchardCore.Data.YesSql dependency from OC.Infrastructure "although this may not be a bad idea. I do thinks adding We could add a new project called |
@CrestApps IMHO you don't need For theming using OC Framework in ASP.NET core app (without CMS) you need to configure your startup as following. The only caveat is that you need to create your own // Configure Features and Theming
services.AddOrchardCore().WithFeatures()
.AddTheming().AddMvc();
services.AddOrchardCore().ConfigureServices( svc=>
{
svc.AddScoped<IShellFeaturesManager, MyFeaturesManager>();
svc.AddScoped<IThemeSelector, MyThemeSelector>();
}); MyFeaturesManager ( same code as public class MyFeaturesManager : IShellFeaturesManager
{
private readonly IExtensionManager _extensionManager;
private readonly ShellDescriptor _shellDescriptor;
public MyFeaturesManager(
IExtensionManager extensionManager,
ShellDescriptor shellDescriptor
)
{
_extensionManager = extensionManager;
_shellDescriptor = shellDescriptor;
}
public Task<IEnumerable<IFeatureInfo>> GetEnabledFeaturesAsync()
{
return Task.FromResult(_extensionManager.GetFeatures().Where(f => _shellDescriptor.Features.Any(sf => sf.Id == f.Id)));
}
public Task<IEnumerable<IFeatureInfo>> GetAlwaysEnabledFeaturesAsync()
{
return Task.FromResult(_extensionManager.GetFeatures().Where(f => f.IsAlwaysEnabled || _shellDescriptor.Features.Any(sf => sf.Id == f.Id && sf.AlwaysEnabled)));
}
public Task<IEnumerable<IFeatureInfo>> GetDisabledFeaturesAsync()
{
return Task.FromResult(_extensionManager.GetFeatures().Where(f => _shellDescriptor.Features.All(sf => sf.Id != f.Id)));
}
public Task<(IEnumerable<IFeatureInfo>, IEnumerable<IFeatureInfo>)> UpdateFeaturesAsync(IEnumerable<IFeatureInfo> featuresToDisable, IEnumerable<IFeatureInfo> featuresToEnable, bool force)
{
throw new NotSupportedException();
}
public Task<IEnumerable<IExtensionInfo>> GetEnabledExtensionsAsync()
{
// enabled extensions are those which have at least one enabled feature.
var enabledIds = _extensionManager.GetFeatures().Where(f => _shellDescriptor
.Features.Any(sf => sf.Id == f.Id)).Select(f => f.Extension.Id).Distinct().ToArray();
// Extensions are still ordered according to the weight of their first features.
return Task.FromResult(_extensionManager.GetExtensions().Where(e => enabledIds.Contains(e.Id)));
}
} |
I will look at it tomorrow more in depth if I have time. As stated by @ns8482e you may not need to call For info when we use OrchardCore/src/OrchardCore/OrchardCore/Modules/Extensions/OrchardCoreBuilderExtensions.cs Lines 57 to 74 in 1586fa0
Then it depends from which source you want to define the feature states, simple to manage fixed states, more complex with dynamic states as you may have to call handlers and so on. Yes I understand the need to only override the store part, hmm but it may be a sensitive part as we may do things that are related to the YesSql behavior, e.g. OrchardCore/src/OrchardCore/OrchardCore.Infrastructure/Shell/ShellDescriptorManager.cs Lines 118 to 123 in 1586fa0
But if you only need fixed states per tenant, you could just register a simple implementation of |
The issue is OrchardCore/src/OrchardCore/OrchardCore.Infrastructure/Shell/ShellOrchardCoreBuilderExtensions.cs Lines 21 to 23 in 1586fa0
So one solution would be move ID registration of |
@ns8482e Ah okay thanks Yes, I only looked at Yes I agree, here only In the meantime can be splitted by using custom OC builder extensions |
Verified that following works - I guess if services.AddOrchardCore()
.AddMvc()
.WithTenants()
.AddTheming()
.ConfigureServices(svc =>
{
svc.AddScoped<IShellFeaturesManager, ShellFeaturesManager>();
svc.AddScoped<IShellDescriptorFeaturesManager,ShellDescriptorFeaturesManager>();
svc.AddScoped<IThemeSelector, MyThemeSelector>();
}); and appsettings.json {
"OrchardCore": {
"Default": {
"State": "Running",
"Features": ["Theme1", "Theme2"]
}
}
} |
@jtkech since I no longer need |
@CrestApps Yes, we already use this for Hmm, maybe Then not sure about Lines 12 to 20 in 1586fa0
Hmm, but yes the above extension is defined in
Thanks for confirming it, yes would be good I think, maybe worth that you suggest a PR for this. |
We could abstract this storage services and be able to provide other ways that don't use yessql, or even SQL in general. |
Issue was closed but ShellDescriptorManager still depends on YesSql.ISession I think ISession have to be replaced by IDocumentStore. |
…YesSql.ISession
Is your feature request related to a problem? Please describe.
I am trying to use OrchardCore framework outside of the CMS in one of my projects. I want to use theming component so I configured the services like this
The
.AddDataStorage()
extension registers ShellDescriptorManager class. However,ShellDescriptorManager
seems to depend onYesSql.ISession
In my case, I am not usingYesSql.ISession
like the CMS does.Describe the solution you'd like
I think we should create
IShellDescriptorStore
which and inject it intoShellDescriptorManager
instead of injectingISession
.The
IShellDescriptorStore
would look something like this.Then we can create
ShellDescriptorStore
which depends onYesSql.ISession
to make it easier to replace implementations and removed theYesSql.ISession
dependency.Describe alternatives you've considered
Currently, I implemented
IShellDescriptorManager
usingCustomShellDescriptorManager
class. Then replace the default implementation like soIf
IShellDescriptorStore
is an acceptable approach, I can send in a pull request.The text was updated successfully, but these errors were encountered: