Refactors IDomain model, simplifies it so that it doesn't contain references, simplifies the domain repository to no longer require lookups of content and languages, updates all other code referencing IDomain and now if a language lookup is required it is made when appropriate.

This commit is contained in:
Shannon
2015-07-27 12:53:09 +02:00
parent 00c13b9939
commit 16c9ca9e4b
23 changed files with 323 additions and 439 deletions

View File

@@ -83,10 +83,23 @@ namespace Umbraco.Web.Models
if (domain == null)
return GetDefaultCulture(localizationService);
var wcDomain = DomainHelper.FindWildcardDomainInPath(domainService.GetAll(true), contentPath, domain.RootContent.Id);
return wcDomain == null
? new CultureInfo(domain.Language.IsoCode)
: new CultureInfo(wcDomain.Language.IsoCode);
//NOTE: The domain service IDomain model has changed and no longer holds a reference to IContent or ILanguage to
// improve performance, this means that we need to lookup the language below, but this was already the case previously
// in the repository and since the language lookup is cached it should be ok. If we want however we could create
// another method on the DomainService to return domains with their culture info on them
var wcDomain = DomainHelper.FindWildcardDomainInPath(domainService.GetAll(true), contentPath, domain.RootContentId);
if (wcDomain != null && wcDomain.LanguageId.HasValue)
{
var lang = localizationService.GetLanguageById(wcDomain.LanguageId.Value);
if (lang != null) return new CultureInfo(lang.IsoCode);
}
else if (domain.LanguageId.HasValue)
{
var lang = localizationService.GetLanguageById(domain.LanguageId.Value);
if (lang != null) return new CultureInfo(lang.IsoCode);
}
return GetDefaultCulture(localizationService);
}
private static CultureInfo GetDefaultCulture(ILocalizationService localizationService)