Ejemplo n.º 1
0
        /// <summary>
        /// Gets the runtime theme variables as specified in the theme's config file
        /// alongside the merged user-defined variables
        /// </summary>
        public static dynamic GetThemeVariables(this IDisplayHelper displayHelper)
        {
            return(displayHelper.HttpContext.GetItem("ThemeVariables", () =>
            {
                var services = displayHelper.HttpContext.RequestServices;
                var storeContext = services.GetService <IStoreContext>();
                var themeManifest = displayHelper.GetThemeManifest();

                if (storeContext == null || themeManifest == null)
                {
                    return new ExpandoObject();
                }
                else
                {
                    var repo = services.GetService <ThemeVariableRepository>();
                    return repo.GetRawVariablesAsync(themeManifest.ThemeName, storeContext.CurrentStore.Id).Await();
                }
            }));
        }