/// <summary> /// This assigns the published content to the request, developers can override this to specify /// any other custom attributes required. /// </summary> /// <param name="pcr"></param> /// <param name="filterContext"></param> protected virtual void ConfigurePublishedContentRequest(PublishedContentRequest pcr, ActionExecutedContext filterContext) { if (_contentId.HasValue) { var content = Umbraco.TypedContent(_contentId); if (content == null) { throw new InvalidOperationException("Could not resolve content with id " + _contentId); } pcr.PublishedContent = content; } else if (_dataTokenName.IsNullOrWhiteSpace() == false) { var result = filterContext.RouteData.DataTokens[_dataTokenName]; if (result == null) { throw new InvalidOperationException("No data token could be found with the name " + _dataTokenName); } if ((result is IPublishedContent) == false) { throw new InvalidOperationException("The data token resolved with name " + _dataTokenName + " was not an instance of " + typeof(IPublishedContent)); } pcr.PublishedContent = (IPublishedContent) result; } //need to set the culture for this to work if (_culture.IsNullOrWhiteSpace()) { //none specified so get the default var defaultLanguage = Language.GetAllAsList().FirstOrDefault(); pcr.Culture = defaultLanguage == null ? CultureInfo.CurrentUICulture : new CultureInfo(defaultLanguage.CultureAlias); } else { pcr.Culture = new CultureInfo(_culture); } pcr.ConfigureRequest(); }