public MembershipHelper ( IUmbracoContextAccessor accessor, MembershipProvider membershipProvider, RoleProvider roleProvider, IMemberService memberService, IMemberTypeService memberTypeService, IUserService userService, IPublicAccessService publicAccessService, PublishedRouter publishedRouter, CacheHelper appCaches, ILogger logger ) { _umbracoContextAccessor = accessor ?? throw new ArgumentNullException(nameof(accessor)); _memberService = memberService; _memberTypeService = memberTypeService; _userService = userService; _publicAccessService = publicAccessService; _publishedRouter = publishedRouter; _appCaches = appCaches; _logger = logger; _membershipProvider = membershipProvider ?? throw new ArgumentNullException(nameof(membershipProvider)); _roleProvider = roleProvider ?? throw new ArgumentNullException(nameof(roleProvider)); }
public ContentUrlResolver( IUmbracoContextAccessor umbracoContextAccessor, PublishedRouter publishedRouter, ILocalizationService localizationService, ILocalizedTextService textService, IContentService contentService, ILogger logger) { _umbracoContextAccessor = umbracoContextAccessor ?? throw new System.ArgumentNullException(nameof(umbracoContextAccessor)); _publishedRouter = publishedRouter ?? throw new System.ArgumentNullException(nameof(publishedRouter)); _localizationService = localizationService ?? throw new System.ArgumentNullException(nameof(localizationService)); _textService = textService ?? throw new System.ArgumentNullException(nameof(textService)); _contentService = contentService ?? throw new System.ArgumentNullException(nameof(contentService)); _logger = logger ?? throw new System.ArgumentNullException(nameof(logger)); }
public UmbracoInjectedModule( IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, IPublishedSnapshotService publishedSnapshotService, IUserService userService, UrlProviderCollection urlProviders, IRuntimeState runtime, ILogger logger, PublishedRouter publishedRouter, IVariationContextAccessor variationContextAccessor) { _combinedRouteCollection = new Lazy <RouteCollection>(CreateRouteCollection); _globalSettings = globalSettings; _umbracoContextAccessor = umbracoContextAccessor; _publishedSnapshotService = publishedSnapshotService; _userService = userService; _urlProviders = urlProviders; _runtime = runtime; _logger = logger; _publishedRouter = publishedRouter; _variationContextAccessor = variationContextAccessor; }
public void Render(StringWriter writer) { if (writer == null) { throw new ArgumentNullException(nameof(writer)); } // instantiate a request and process // important to use CleanedUmbracoUrl - lowercase path-only version of the current url, though this isn't going to matter // terribly much for this implementation since we are just creating a doc content request to modify it's properties manually. var contentRequest = PublishedRouter.CreateRequest(_umbracoContext); var doc = contentRequest.UmbracoContext.ContentCache.GetById(PageId); if (doc == null) { writer.Write("<!-- Could not render template for Id {0}, the document was not found -->", PageId); return; } //in some cases the UmbracoContext will not have a PublishedContentRequest assigned to it if we are not in the //execution of a front-end rendered page. In this case set the culture to the default. //set the culture to the same as is currently rendering if (_umbracoContext.PublishedRequest == null) { var defaultLanguage = Current.Services.LocalizationService.GetAllLanguages().FirstOrDefault(); contentRequest.Culture = defaultLanguage == null ? CultureInfo.CurrentUICulture : defaultLanguage.CultureInfo; } else { contentRequest.Culture = _umbracoContext.PublishedRequest.Culture; } //set the doc that was found by id contentRequest.PublishedContent = doc; //set the template, either based on the AltTemplate found or the standard template of the doc var templateId = Current.Configs.Settings().WebRouting.DisableAlternativeTemplates || !AltTemplateId.HasValue ? doc.TemplateId : AltTemplateId.Value; if (templateId.HasValue) { contentRequest.TemplateModel = FileService.GetTemplate(templateId.Value); } //if there is not template then exit if (contentRequest.HasTemplate == false) { if (AltTemplateId.HasValue == false) { writer.Write("<!-- Could not render template for Id {0}, the document's template was not found with id {0}-->", doc.TemplateId); } else { writer.Write("<!-- Could not render template for Id {0}, the altTemplate was not found with id {0}-->", AltTemplateId); } return; } //First, save all of the items locally that we know are used in the chain of execution, we'll need to restore these //after this page has rendered. SaveExistingItems(); try { //set the new items on context objects for this templates execution SetNewItemsOnContextObjects(contentRequest); //Render the template ExecuteTemplateRendering(writer, contentRequest); } finally { //restore items on context objects to continuing rendering the parent template RestoreItems(); } }