Move IPublishedContent.Url() to ext method
This commit is contained in:
@@ -93,20 +93,6 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
/// </remarks>
|
||||
DateTime UpdateDate { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the url of the content item.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>If the content item is a document, then this method returns the url of the
|
||||
/// document. If it is a media, then this methods return the media url for the
|
||||
/// 'umbracoFile' property. Use the MediaUrl() method to get the media url for other
|
||||
/// properties.</para>
|
||||
/// <para>The value of this property is contextual. It depends on the 'current' request uri,
|
||||
/// if any. In addition, when the content type is multi-lingual, this is the url for the
|
||||
/// specified culture. Otherwise, it is the invariant url.</para>
|
||||
/// </remarks>
|
||||
string Url(string culture = null, UrlMode mode = UrlMode.Auto);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the culture date of the content item.
|
||||
/// </summary>
|
||||
|
||||
@@ -93,9 +93,6 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
/// <inheritdoc />
|
||||
public virtual DateTime UpdateDate => _content.UpdateDate;
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual string Url(string culture = null, UrlMode mode = UrlMode.Auto) => _content.Url(culture, mode);
|
||||
|
||||
/// <inheritdoc />
|
||||
public DateTime CultureDate(string culture = null) => _content.CultureDate(culture);
|
||||
|
||||
|
||||
@@ -68,9 +68,9 @@ namespace Umbraco.Tests.Cache.PublishedCache
|
||||
var appCache = new DictionaryAppCache();
|
||||
var domainCache = new DomainCache(ServiceContext.DomainService, DefaultCultureAccessor);
|
||||
var publishedShapshot = new PublishedSnapshot(
|
||||
new PublishedContentCache(xmlStore, domainCache, appCache, globalSettings, new SiteDomainHelper(), umbracoContextAccessor, ContentTypesCache, null, null),
|
||||
new PublishedContentCache(xmlStore, domainCache, appCache, globalSettings, ContentTypesCache, null, null),
|
||||
new PublishedMediaCache(xmlStore, ServiceContext.MediaService, ServiceContext.UserService, appCache, ContentTypesCache, Factory.GetInstance<IEntityXmlSerializer>(), umbracoContextAccessor),
|
||||
new PublishedMemberCache(null, appCache, Current.Services.MemberService, ContentTypesCache, umbracoContextAccessor),
|
||||
new PublishedMemberCache(null, appCache, Current.Services.MemberService, ContentTypesCache),
|
||||
domainCache);
|
||||
var publishedSnapshotService = new Mock<IPublishedSnapshotService>();
|
||||
publishedSnapshotService.Setup(x => x.CreatePublishedSnapshot(It.IsAny<string>())).Returns(publishedShapshot);
|
||||
|
||||
@@ -323,8 +323,7 @@ namespace Umbraco.Tests.Cache.PublishedCache
|
||||
// no xpath
|
||||
null,
|
||||
// not from examine
|
||||
false,
|
||||
_umbracoContextAccessor),
|
||||
false),
|
||||
//callback to get the children
|
||||
(dd, n) => children,
|
||||
// callback to get a property
|
||||
@@ -334,8 +333,7 @@ namespace Umbraco.Tests.Cache.PublishedCache
|
||||
// no xpath
|
||||
null,
|
||||
// not from examine
|
||||
false,
|
||||
_umbracoContextAccessor);
|
||||
false);
|
||||
return dicDoc;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.Composing;
|
||||
using Umbraco.Web.Models;
|
||||
using Umbraco.Web.PublishedCache;
|
||||
@@ -40,9 +39,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
|
||||
IAppCache appCache,
|
||||
PublishedContentTypeCache contentTypeCache,
|
||||
XPathNavigator nav,
|
||||
bool fromExamine,
|
||||
IUmbracoContextAccessor umbracoContextAccessor)
|
||||
:base(umbracoContextAccessor)
|
||||
bool fromExamine)
|
||||
{
|
||||
if (valueDictionary == null) throw new ArgumentNullException(nameof(valueDictionary));
|
||||
if (getParent == null) throw new ArgumentNullException(nameof(getParent));
|
||||
|
||||
@@ -9,7 +9,6 @@ using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Core.Xml;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.PublishedCache;
|
||||
using Umbraco.Web.Routing;
|
||||
|
||||
@@ -19,7 +18,6 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
|
||||
{
|
||||
private readonly IAppCache _appCache;
|
||||
private readonly IGlobalSettings _globalSettings;
|
||||
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
|
||||
private readonly RoutesCache _routesCache;
|
||||
private readonly IDomainCache _domainCache;
|
||||
private readonly PublishedContentTypeCache _contentTypeCache;
|
||||
@@ -34,8 +32,6 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
|
||||
IDomainCache domainCache, // an IDomainCache implementation
|
||||
IAppCache appCache, // an IAppCache that should be at request-level
|
||||
IGlobalSettings globalSettings,
|
||||
ISiteDomainHelper siteDomainHelper,
|
||||
IUmbracoContextAccessor umbracoContextAccessor,
|
||||
PublishedContentTypeCache contentTypeCache, // a PublishedContentType cache
|
||||
RoutesCache routesCache, // a RoutesCache
|
||||
string previewToken) // a preview token string (or null if not previewing)
|
||||
@@ -43,7 +39,6 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
|
||||
{
|
||||
_appCache = appCache;
|
||||
_globalSettings = globalSettings;
|
||||
_umbracoContextAccessor = umbracoContextAccessor;
|
||||
_routesCache = routesCache; // may be null for unit-testing
|
||||
_contentTypeCache = contentTypeCache;
|
||||
_domainCache = domainCache;
|
||||
@@ -318,13 +313,13 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
|
||||
|
||||
private IPublishedContent ConvertToDocument(XmlNode xmlNode, bool isPreviewing)
|
||||
{
|
||||
return xmlNode == null ? null : XmlPublishedContent.Get(xmlNode, isPreviewing, _appCache, _contentTypeCache,_umbracoContextAccessor);
|
||||
return xmlNode == null ? null : XmlPublishedContent.Get(xmlNode, isPreviewing, _appCache, _contentTypeCache);
|
||||
}
|
||||
|
||||
private IEnumerable<IPublishedContent> ConvertToDocuments(XmlNodeList xmlNodes, bool isPreviewing)
|
||||
{
|
||||
return xmlNodes.Cast<XmlNode>()
|
||||
.Select(xmlNode => XmlPublishedContent.Get(xmlNode, isPreviewing, _appCache, _contentTypeCache, _umbracoContextAccessor));
|
||||
.Select(xmlNode => XmlPublishedContent.Get(xmlNode, isPreviewing, _appCache, _contentTypeCache));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -674,8 +674,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
|
||||
_appCache,
|
||||
_contentTypeCache,
|
||||
cacheValues.XPath, // though, outside of tests, that should be null
|
||||
cacheValues.FromExamine,
|
||||
_umbracoContextAccessor
|
||||
cacheValues.FromExamine
|
||||
);
|
||||
return content.CreateModel();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Core.Security;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.PublishedCache;
|
||||
using Umbraco.Web.Security;
|
||||
|
||||
@@ -18,16 +17,13 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
|
||||
private readonly IAppCache _requestCache;
|
||||
private readonly XmlStore _xmlStore;
|
||||
private readonly PublishedContentTypeCache _contentTypeCache;
|
||||
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
|
||||
|
||||
public PublishedMemberCache(XmlStore xmlStore, IAppCache requestCache, IMemberService memberService,
|
||||
PublishedContentTypeCache contentTypeCache, IUmbracoContextAccessor umbracoContextAccessor)
|
||||
public PublishedMemberCache(XmlStore xmlStore, IAppCache requestCache, IMemberService memberService, PublishedContentTypeCache contentTypeCache)
|
||||
{
|
||||
_requestCache = requestCache;
|
||||
_memberService = memberService;
|
||||
_xmlStore = xmlStore;
|
||||
_contentTypeCache = contentTypeCache;
|
||||
_umbracoContextAccessor = umbracoContextAccessor;
|
||||
}
|
||||
|
||||
public IPublishedContent GetByProviderKey(object key)
|
||||
@@ -44,7 +40,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
|
||||
var result = _memberService.GetByProviderKey(key);
|
||||
if (result == null) return null;
|
||||
var type = _contentTypeCache.Get(PublishedItemType.Member, result.ContentTypeId);
|
||||
return new PublishedMember(result, type, _umbracoContextAccessor).CreateModel();
|
||||
return new PublishedMember(result, type).CreateModel();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -62,7 +58,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
|
||||
var result = _memberService.GetById(memberId);
|
||||
if (result == null) return null;
|
||||
var type = _contentTypeCache.Get(PublishedItemType.Member, result.ContentTypeId);
|
||||
return new PublishedMember(result, type, _umbracoContextAccessor).CreateModel();
|
||||
return new PublishedMember(result, type).CreateModel();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -80,7 +76,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
|
||||
var result = _memberService.GetByUsername(username);
|
||||
if (result == null) return null;
|
||||
var type = _contentTypeCache.Get(PublishedItemType.Member, result.ContentTypeId);
|
||||
return new PublishedMember(result, type, _umbracoContextAccessor).CreateModel();
|
||||
return new PublishedMember(result, type).CreateModel();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -98,14 +94,14 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
|
||||
var result = _memberService.GetByEmail(email);
|
||||
if (result == null) return null;
|
||||
var type = _contentTypeCache.Get(PublishedItemType.Member, result.ContentTypeId);
|
||||
return new PublishedMember(result, type, _umbracoContextAccessor).CreateModel();
|
||||
return new PublishedMember(result, type).CreateModel();
|
||||
});
|
||||
}
|
||||
|
||||
public IPublishedContent GetByMember(IMember member)
|
||||
{
|
||||
var type = _contentTypeCache.Get(PublishedItemType.Member, member.ContentTypeId);
|
||||
return new PublishedMember(member, type, _umbracoContextAccessor).CreateModel();
|
||||
return new PublishedMember(member, type).CreateModel();
|
||||
}
|
||||
|
||||
public XPathNavigator CreateNavigator()
|
||||
|
||||
@@ -145,9 +145,9 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
|
||||
var domainCache = new DomainCache(_domainService, _defaultCultureAccessor);
|
||||
|
||||
return new PublishedSnapshot(
|
||||
new PublishedContentCache(_xmlStore, domainCache, _requestCache, _globalSettings, _siteDomainHelper,_umbracoContextAccessor, _contentTypeCache, _routesCache, previewToken),
|
||||
new PublishedContentCache(_xmlStore, domainCache, _requestCache, _globalSettings, _contentTypeCache, _routesCache, previewToken),
|
||||
new PublishedMediaCache(_xmlStore, _mediaService, _userService, _requestCache, _contentTypeCache, _entitySerializer, _umbracoContextAccessor),
|
||||
new PublishedMemberCache(_xmlStore, _requestCache, _memberService, _contentTypeCache, _umbracoContextAccessor),
|
||||
new PublishedMemberCache(_xmlStore, _requestCache, _memberService, _contentTypeCache),
|
||||
domainCache);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,23 +26,19 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
|
||||
XmlNode xmlNode,
|
||||
bool isPreviewing,
|
||||
IAppCache appCache,
|
||||
PublishedContentTypeCache contentTypeCache,
|
||||
IUmbracoContextAccessor umbracoContextAccessor)
|
||||
:base(umbracoContextAccessor)
|
||||
PublishedContentTypeCache contentTypeCache)
|
||||
{
|
||||
_xmlNode = xmlNode;
|
||||
_isPreviewing = isPreviewing;
|
||||
|
||||
_appCache = appCache;
|
||||
_contentTypeCache = contentTypeCache;
|
||||
_umbracoContextAccessor = umbracoContextAccessor;
|
||||
}
|
||||
|
||||
private readonly XmlNode _xmlNode;
|
||||
private readonly bool _isPreviewing;
|
||||
private readonly IAppCache _appCache; // at snapshot/request level (see PublishedContentCache)
|
||||
private readonly PublishedContentTypeCache _contentTypeCache;
|
||||
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
|
||||
|
||||
private readonly object _initializeLock = new object();
|
||||
|
||||
@@ -256,7 +252,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
|
||||
if (parent == null) return;
|
||||
|
||||
if (parent.Attributes?.GetNamedItem("isDoc") != null)
|
||||
_parent = Get(parent, _isPreviewing, _appCache, _contentTypeCache, _umbracoContextAccessor);
|
||||
_parent = Get(parent, _isPreviewing, _appCache, _contentTypeCache);
|
||||
|
||||
_parentInitialized = true;
|
||||
}
|
||||
@@ -413,7 +409,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
|
||||
var iterator = nav.Select(expr);
|
||||
|
||||
_children = iterator.Cast<XPathNavigator>()
|
||||
.Select(n => Get(((IHasXmlNode) n).GetNode(), _isPreviewing, _appCache, _contentTypeCache, _umbracoContextAccessor))
|
||||
.Select(n => Get(((IHasXmlNode) n).GetNode(), _isPreviewing, _appCache, _contentTypeCache))
|
||||
.OrderBy(x => x.SortOrder)
|
||||
.ToList();
|
||||
|
||||
@@ -433,7 +429,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
|
||||
/// sure that we create only one instance of each for the duration of a request. The
|
||||
/// returned IPublishedContent is a model, if models are enabled.</remarks>
|
||||
public static IPublishedContent Get(XmlNode node, bool isPreviewing, IAppCache appCache,
|
||||
PublishedContentTypeCache contentTypeCache, IUmbracoContextAccessor umbracoContextAccessor)
|
||||
PublishedContentTypeCache contentTypeCache)
|
||||
{
|
||||
// only 1 per request
|
||||
|
||||
@@ -441,7 +437,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
|
||||
var id = attrs?.GetNamedItem("id").Value;
|
||||
if (id.IsNullOrWhiteSpace()) throw new InvalidOperationException("Node has no ID attribute.");
|
||||
var key = CacheKeyPrefix + id; // dont bother with preview, wont change during request in Xml cache
|
||||
return (IPublishedContent) appCache.Get(key, () => (new XmlPublishedContent(node, isPreviewing, appCache, contentTypeCache, umbracoContextAccessor)).CreateModel());
|
||||
return (IPublishedContent) appCache.Get(key, () => (new XmlPublishedContent(node, isPreviewing, appCache, contentTypeCache)).CreateModel());
|
||||
}
|
||||
|
||||
public static void ClearRequest()
|
||||
|
||||
@@ -172,7 +172,7 @@ namespace Umbraco.Tests.Published
|
||||
new TestPublishedProperty(contentType1.GetPropertyType("property1"), $@"[
|
||||
{{ ""key"": ""{keyA}"", ""propertyN1"": ""foo"", ""ncContentTypeAlias"": ""contentN1"" }}
|
||||
]")
|
||||
}, Mock.Of<IUmbracoContextAccessor>());
|
||||
});
|
||||
var value = content.Value("property1");
|
||||
|
||||
// nested single converter returns proper TestModel value
|
||||
@@ -200,8 +200,7 @@ namespace Umbraco.Tests.Published
|
||||
{{ ""key"": ""{keyA}"", ""propertyN1"": ""foo"", ""ncContentTypeAlias"": ""contentN1"" }},
|
||||
{{ ""key"": ""{keyB}"", ""propertyN1"": ""bar"", ""ncContentTypeAlias"": ""contentN1"" }}
|
||||
]")
|
||||
},
|
||||
Mock.Of<IUmbracoContextAccessor>());
|
||||
});
|
||||
var value = content.Value("property2");
|
||||
|
||||
// nested many converter returns proper IEnumerable<TestModel> value
|
||||
@@ -261,7 +260,7 @@ namespace Umbraco.Tests.Published
|
||||
|
||||
class TestPublishedContent : PublishedContentBase
|
||||
{
|
||||
public TestPublishedContent(IPublishedContentType contentType, Guid key, IEnumerable<TestPublishedProperty> properties, IUmbracoContextAccessor umbracoContextAccessor): base(umbracoContextAccessor)
|
||||
public TestPublishedContent(IPublishedContentType contentType, Guid key, IEnumerable<TestPublishedProperty> properties)
|
||||
{
|
||||
ContentType = contentType;
|
||||
Key = key;
|
||||
|
||||
@@ -24,7 +24,6 @@ using Umbraco.Web.Cache;
|
||||
using Umbraco.Web.PublishedCache;
|
||||
using Umbraco.Web.PublishedCache.NuCache;
|
||||
using Umbraco.Web.PublishedCache.NuCache.DataSource;
|
||||
using Umbraco.Web.Routing;
|
||||
|
||||
namespace Umbraco.Tests.PublishedContent
|
||||
{
|
||||
@@ -171,7 +170,6 @@ namespace Umbraco.Tests.PublishedContent
|
||||
null,
|
||||
new TestPublishedSnapshotAccessor(),
|
||||
_variationAccesor,
|
||||
Mock.Of<IUmbracoContextAccessor>(),
|
||||
Mock.Of<ILogger>(),
|
||||
scopeProvider,
|
||||
Mock.Of<IDocumentRepository>(),
|
||||
@@ -180,7 +178,6 @@ namespace Umbraco.Tests.PublishedContent
|
||||
new TestDefaultCultureAccessor(),
|
||||
dataSource,
|
||||
globalSettings,
|
||||
new SiteDomainHelper(),
|
||||
Mock.Of<IEntityXmlSerializer>(),
|
||||
Mock.Of<IPublishedModelFactory>(),
|
||||
new UrlSegmentProviderCollection(new[] { new DefaultUrlSegmentProvider() }));
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Umbraco.Tests.Routing
|
||||
var umbracoContext = GetUmbracoContext("/", mediaUrlProviders: new[] { _mediaUrlProvider });
|
||||
var publishedContent = CreatePublishedContent(Constants.PropertyEditors.Aliases.UploadField, expected, null);
|
||||
|
||||
var resolvedUrl = umbracoContext.UrlProvider.GetMediaUrl(publishedContent, "umbracoFile", UrlMode.Auto, null, null);
|
||||
var resolvedUrl = umbracoContext.UrlProvider.GetMediaUrl(publishedContent, UrlMode.Auto);
|
||||
|
||||
Assert.AreEqual(expected, resolvedUrl);
|
||||
}
|
||||
@@ -64,7 +64,7 @@ namespace Umbraco.Tests.Routing
|
||||
var umbracoContext = GetUmbracoContext("/", mediaUrlProviders: new[] { _mediaUrlProvider });
|
||||
var publishedContent = CreatePublishedContent(Constants.PropertyEditors.Aliases.ImageCropper, imageCropperValue, configuration);
|
||||
|
||||
var resolvedUrl = umbracoContext.UrlProvider.GetMediaUrl(publishedContent, "umbracoFile", UrlMode.Auto, null, null);
|
||||
var resolvedUrl = umbracoContext.UrlProvider.GetMediaUrl(publishedContent, UrlMode.Auto);
|
||||
|
||||
Assert.AreEqual(expected, resolvedUrl);
|
||||
}
|
||||
@@ -78,7 +78,7 @@ namespace Umbraco.Tests.Routing
|
||||
var umbracoContext = GetUmbracoContext("http://localhost", mediaUrlProviders: new[] { _mediaUrlProvider });
|
||||
var publishedContent = CreatePublishedContent(Constants.PropertyEditors.Aliases.UploadField, mediaUrl, null);
|
||||
|
||||
var resolvedUrl = umbracoContext.UrlProvider.GetMediaUrl(publishedContent, "umbracoFile", UrlMode.Absolute, null, null);
|
||||
var resolvedUrl = umbracoContext.UrlProvider.GetMediaUrl(publishedContent, UrlMode.Absolute);
|
||||
|
||||
Assert.AreEqual(expected, resolvedUrl);
|
||||
}
|
||||
@@ -89,7 +89,7 @@ namespace Umbraco.Tests.Routing
|
||||
var umbracoContext = GetUmbracoContext("/", mediaUrlProviders: new[] { _mediaUrlProvider });
|
||||
var publishedContent = CreatePublishedContent(Constants.PropertyEditors.Aliases.Boolean, "0", null);
|
||||
|
||||
var resolvedUrl = umbracoContext.UrlProvider.GetMediaUrl(publishedContent, "test", UrlMode.Absolute, null, null);
|
||||
var resolvedUrl = umbracoContext.UrlProvider.GetMediaUrl(publishedContent, UrlMode.Absolute, propertyAlias: "test");
|
||||
|
||||
Assert.AreEqual(string.Empty, resolvedUrl);
|
||||
}
|
||||
@@ -116,7 +116,7 @@ namespace Umbraco.Tests.Routing
|
||||
var contentType = new PublishedContentType(666, "alias", PublishedItemType.Content, Enumerable.Empty<string>(), new [] { umbracoFilePropertyType }, ContentVariation.Culture);
|
||||
var publishedContent = new SolidPublishedContent(contentType) {Properties = new[] {property}};
|
||||
|
||||
var resolvedUrl = umbracoContext.UrlProvider.GetMediaUrl(publishedContent, "umbracoFile", UrlMode.Auto, "da", null);
|
||||
var resolvedUrl = umbracoContext.UrlProvider.GetMediaUrl(publishedContent, UrlMode.Auto, "da");
|
||||
Assert.AreEqual(daMediaUrl, resolvedUrl);
|
||||
}
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ namespace Umbraco.Tests.Routing
|
||||
snapshotService: snapshotService.Object);
|
||||
|
||||
//even though we are asking for a specific culture URL, there are no domains assigned so all that can be returned is a normal relative url.
|
||||
var url = umbracoContext.UrlProvider.GetUrl(1234, "fr-FR");
|
||||
var url = umbracoContext.UrlProvider.GetUrl(1234, culture: "fr-FR");
|
||||
|
||||
Assert.AreEqual("/home/test-fr/", url);
|
||||
}
|
||||
@@ -239,7 +239,7 @@ namespace Umbraco.Tests.Routing
|
||||
snapshotService: snapshotService.Object);
|
||||
|
||||
|
||||
var url = umbracoContext.UrlProvider.GetUrl(1234, "fr-FR");
|
||||
var url = umbracoContext.UrlProvider.GetUrl(1234, culture: "fr-FR");
|
||||
|
||||
Assert.AreEqual("/home/test-fr/", url);
|
||||
}
|
||||
@@ -293,7 +293,7 @@ namespace Umbraco.Tests.Routing
|
||||
snapshotService: snapshotService.Object);
|
||||
|
||||
|
||||
var url = umbracoContext.UrlProvider.GetUrl(1234, "fr-FR");
|
||||
var url = umbracoContext.UrlProvider.GetUrl(1234, culture: "fr-FR");
|
||||
|
||||
//the current uri is not the culture specific domain we want, so the result is an absolute path to the culture specific domain
|
||||
Assert.AreEqual("http://example.fr/home/test-fr/", url);
|
||||
|
||||
@@ -92,13 +92,12 @@ namespace Umbraco.Tests.Scoping
|
||||
null,
|
||||
publishedSnapshotAccessor,
|
||||
Mock.Of<IVariationContextAccessor>(),
|
||||
Mock.Of<IUmbracoContextAccessor>(),
|
||||
Logger,
|
||||
ScopeProvider,
|
||||
documentRepository, mediaRepository, memberRepository,
|
||||
DefaultCultureAccessor,
|
||||
new DatabaseDataSource(),
|
||||
Factory.GetInstance<IGlobalSettings>(), new SiteDomainHelper(),
|
||||
Factory.GetInstance<IGlobalSettings>(),
|
||||
Factory.GetInstance<IEntityXmlSerializer>(),
|
||||
Mock.Of<IPublishedModelFactory>(),
|
||||
new UrlSegmentProviderCollection(new[] { new DefaultUrlSegmentProvider() }));
|
||||
|
||||
@@ -18,11 +18,9 @@ using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Core.Sync;
|
||||
using Umbraco.Tests.Testing;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.PublishedCache;
|
||||
using Umbraco.Web.PublishedCache.NuCache;
|
||||
using Umbraco.Web.PublishedCache.NuCache.DataSource;
|
||||
using Umbraco.Web.Routing;
|
||||
|
||||
namespace Umbraco.Tests.Services
|
||||
{
|
||||
@@ -65,13 +63,12 @@ namespace Umbraco.Tests.Services
|
||||
null,
|
||||
publishedSnapshotAccessor,
|
||||
Mock.Of<IVariationContextAccessor>(),
|
||||
Mock.Of<IUmbracoContextAccessor>(),
|
||||
Logger,
|
||||
ScopeProvider,
|
||||
documentRepository, mediaRepository, memberRepository,
|
||||
DefaultCultureAccessor,
|
||||
new DatabaseDataSource(),
|
||||
Factory.GetInstance<IGlobalSettings>(), new SiteDomainHelper(),
|
||||
Factory.GetInstance<IGlobalSettings>(),
|
||||
Factory.GetInstance<IEntityXmlSerializer>(),
|
||||
Mock.Of<IPublishedModelFactory>(),
|
||||
new UrlSegmentProviderCollection(new[] { new DefaultUrlSegmentProvider() }));
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
target.ContentId = source.ContentId;
|
||||
target.CreateDateUtc = source.CreateDateUtc;
|
||||
target.Culture = source.Culture;
|
||||
target.DestinationUrl = source.ContentId > 0 ? UmbracoContext?.UrlProvider?.GetUrl(source.ContentId, source.Culture) : "#";
|
||||
target.DestinationUrl = source.ContentId > 0 ? UmbracoContext?.UrlProvider?.GetUrl(source.ContentId, culture: source.Culture) : "#";
|
||||
target.OriginalUrl = UmbracoContext?.UrlProvider?.GetUrlFromRoute(source.ContentId, source.Url, source.Culture);
|
||||
target.RedirectId = source.Key;
|
||||
}
|
||||
|
||||
@@ -15,13 +15,6 @@ namespace Umbraco.Web.Models
|
||||
[DebuggerDisplay("Content Id: {Id}}")]
|
||||
public abstract class PublishedContentBase : IPublishedContent
|
||||
{
|
||||
protected PublishedContentBase(IUmbracoContextAccessor umbracoContextAccessor)
|
||||
{
|
||||
UmbracoContextAccessor = umbracoContextAccessor ?? throw new ArgumentNullException(nameof(umbracoContextAccessor));
|
||||
}
|
||||
|
||||
protected IUmbracoContextAccessor UmbracoContextAccessor { get; }
|
||||
|
||||
#region ContentType
|
||||
|
||||
public abstract IPublishedContentType ContentType { get; }
|
||||
@@ -76,32 +69,6 @@ namespace Umbraco.Web.Models
|
||||
/// <inheritdoc />
|
||||
public abstract DateTime UpdateDate { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <remarks>
|
||||
/// The url of documents are computed by the document url providers. The url of medias are computed by the media url providers.
|
||||
/// </remarks>
|
||||
public virtual string Url(string culture = null, UrlMode mode = UrlMode.Auto)
|
||||
{
|
||||
var umbracoContext = UmbracoContextAccessor.UmbracoContext;
|
||||
|
||||
if (umbracoContext == null)
|
||||
throw new InvalidOperationException("Cannot compute Url for a content item when UmbracoContext is null.");
|
||||
if (umbracoContext.UrlProvider == null)
|
||||
throw new InvalidOperationException("Cannot compute Url for a content item when UmbracoContext.UrlProvider is null.");
|
||||
|
||||
switch (ContentType.ItemType)
|
||||
{
|
||||
case PublishedItemType.Content:
|
||||
return umbracoContext.UrlProvider.GetUrl(this, mode, culture);
|
||||
|
||||
case PublishedItemType.Media:
|
||||
return umbracoContext.UrlProvider.GetMediaUrl(this, mode, culture, Constants.Conventions.Media.File);
|
||||
|
||||
default:
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract DateTime CultureDate(string culture = null);
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Web.PublishedCache.NuCache.DataSource;
|
||||
|
||||
@@ -40,11 +39,10 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
DateTime createDate, int creatorId,
|
||||
ContentData draftData, ContentData publishedData,
|
||||
IPublishedSnapshotAccessor publishedSnapshotAccessor,
|
||||
IVariationContextAccessor variationContextAccessor,
|
||||
IUmbracoContextAccessor umbracoContextAccessor)
|
||||
IVariationContextAccessor variationContextAccessor)
|
||||
: this(id, uid, level, path, sortOrder, parentContentId, createDate, creatorId)
|
||||
{
|
||||
SetContentTypeAndData(contentType, draftData, publishedData, publishedSnapshotAccessor, variationContextAccessor, umbracoContextAccessor);
|
||||
SetContentTypeAndData(contentType, draftData, publishedData, publishedSnapshotAccessor, variationContextAccessor);
|
||||
}
|
||||
|
||||
// 2-phases ctor, phase 1
|
||||
@@ -66,7 +64,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
}
|
||||
|
||||
// two-phase ctor, phase 2
|
||||
public void SetContentTypeAndData(IPublishedContentType contentType, ContentData draftData, ContentData publishedData, IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor, IUmbracoContextAccessor umbracoContextAccessor)
|
||||
public void SetContentTypeAndData(IPublishedContentType contentType, ContentData draftData, ContentData publishedData, IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor)
|
||||
{
|
||||
ContentType = contentType;
|
||||
|
||||
@@ -75,13 +73,13 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
if (draftData != null)
|
||||
{
|
||||
DraftContent = new PublishedContent(this, draftData, publishedSnapshotAccessor, variationContextAccessor, umbracoContextAccessor);
|
||||
DraftContent = new PublishedContent(this, draftData, publishedSnapshotAccessor, variationContextAccessor);
|
||||
DraftModel = DraftContent.CreateModel();
|
||||
}
|
||||
|
||||
if (publishedData != null)
|
||||
{
|
||||
PublishedContent = new PublishedContent(this, publishedData, publishedSnapshotAccessor, variationContextAccessor, umbracoContextAccessor);
|
||||
PublishedContent = new PublishedContent(this, publishedData, publishedSnapshotAccessor, variationContextAccessor);
|
||||
PublishedModel = PublishedContent.CreateModel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,8 +21,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
IPublishedContentType contentType,
|
||||
IPublishedSnapshotAccessor publishedSnapshotAccessor,
|
||||
IVariationContextAccessor variationContextAccessor,
|
||||
bool canBePublished,
|
||||
IUmbracoContextAccessor umbracoContextAccessor)
|
||||
bool canBePublished)
|
||||
{
|
||||
var draftData = DraftData;
|
||||
|
||||
@@ -35,7 +34,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
if (draftData == null && !canBePublished)
|
||||
draftData = PublishedData;
|
||||
|
||||
Node.SetContentTypeAndData(contentType, draftData, publishedData, publishedSnapshotAccessor, variationContextAccessor,umbracoContextAccessor);
|
||||
Node.SetContentTypeAndData(contentType, draftData, publishedData, publishedSnapshotAccessor, variationContextAccessor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor;
|
||||
private readonly IVariationContextAccessor _variationContextAccessor;
|
||||
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
|
||||
private readonly ConcurrentDictionary<int, LinkedNode<ContentNode>> _contentNodes;
|
||||
private LinkedNode<ContentNode> _root;
|
||||
private readonly ConcurrentDictionary<int, LinkedNode<IPublishedContentType>> _contentTypesById;
|
||||
@@ -49,13 +48,11 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
public ContentStore(
|
||||
IPublishedSnapshotAccessor publishedSnapshotAccessor,
|
||||
IVariationContextAccessor variationContextAccessor,
|
||||
IUmbracoContextAccessor umbracoContextAccessor,
|
||||
ILogger logger,
|
||||
BPlusTree<int, ContentNodeKit> localDb = null)
|
||||
{
|
||||
_publishedSnapshotAccessor = publishedSnapshotAccessor;
|
||||
_variationContextAccessor = variationContextAccessor;
|
||||
_umbracoContextAccessor = umbracoContextAccessor;
|
||||
_logger = logger;
|
||||
_localDb = localDb;
|
||||
|
||||
@@ -449,7 +446,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
var canBePublished = ParentPublishedLocked(kit);
|
||||
|
||||
// and use
|
||||
kit.Build(link.Value, _publishedSnapshotAccessor, _variationContextAccessor, canBePublished, _umbracoContextAccessor);
|
||||
kit.Build(link.Value, _publishedSnapshotAccessor, _variationContextAccessor, canBePublished);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Core.Security;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Services.Implement;
|
||||
using Umbraco.Core.Xml.XPath;
|
||||
using Umbraco.Web.PublishedCache.NuCache.Navigable;
|
||||
|
||||
@@ -19,7 +18,6 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor;
|
||||
|
||||
public readonly IVariationContextAccessor VariationContextAccessor;
|
||||
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
|
||||
private readonly IEntityXmlSerializer _entitySerializer;
|
||||
private readonly IAppCache _snapshotCache;
|
||||
private readonly IMemberService _memberService;
|
||||
@@ -27,12 +25,11 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
private readonly bool _previewDefault;
|
||||
|
||||
public MemberCache(bool previewDefault, IAppCache snapshotCache, IMemberService memberService, PublishedContentTypeCache contentTypeCache,
|
||||
IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor, IUmbracoContextAccessor umbracoContextAccessor, IEntityXmlSerializer entitySerializer)
|
||||
IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor, IEntityXmlSerializer entitySerializer)
|
||||
{
|
||||
_snapshotCache = snapshotCache;
|
||||
_publishedSnapshotAccessor = publishedSnapshotAccessor;
|
||||
VariationContextAccessor = variationContextAccessor;
|
||||
_umbracoContextAccessor = umbracoContextAccessor;
|
||||
_entitySerializer = entitySerializer;
|
||||
_memberService = memberService;
|
||||
_previewDefault = previewDefault;
|
||||
@@ -68,14 +65,14 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
var member = _memberService.GetById(memberId);
|
||||
return member == null
|
||||
? null
|
||||
: PublishedMember.Create(member, GetContentType(member.ContentTypeId), _previewDefault, _publishedSnapshotAccessor, VariationContextAccessor, _umbracoContextAccessor);
|
||||
: PublishedMember.Create(member, GetContentType(member.ContentTypeId), _previewDefault, _publishedSnapshotAccessor, VariationContextAccessor);
|
||||
});
|
||||
}
|
||||
|
||||
private IPublishedContent /*IPublishedMember*/ GetById(IMember member, bool previewing)
|
||||
{
|
||||
return GetCacheItem(CacheKeys.MemberCacheMember("ById", _previewDefault, member.Id), () =>
|
||||
PublishedMember.Create(member, GetContentType(member.ContentTypeId), previewing, _publishedSnapshotAccessor, VariationContextAccessor, _umbracoContextAccessor));
|
||||
PublishedMember.Create(member, GetContentType(member.ContentTypeId), previewing, _publishedSnapshotAccessor, VariationContextAccessor));
|
||||
}
|
||||
|
||||
public IPublishedContent /*IPublishedMember*/ GetByProviderKey(object key)
|
||||
@@ -110,7 +107,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
public IPublishedContent /*IPublishedMember*/ GetByMember(IMember member)
|
||||
{
|
||||
return PublishedMember.Create(member, GetContentType(member.ContentTypeId), _previewDefault, _publishedSnapshotAccessor, VariationContextAccessor, _umbracoContextAccessor);
|
||||
return PublishedMember.Create(member, GetContentType(member.ContentTypeId), _previewDefault, _publishedSnapshotAccessor, VariationContextAccessor);
|
||||
}
|
||||
|
||||
public IEnumerable<IPublishedContent> GetAtRoot(bool preview)
|
||||
@@ -118,7 +115,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
// because members are flat (not a tree) everything is at root
|
||||
// because we're loading everything... let's just not cache?
|
||||
var members = _memberService.GetAllMembers();
|
||||
return members.Select(m => PublishedMember.Create(m, GetContentType(m.ContentTypeId), preview, _publishedSnapshotAccessor, VariationContextAccessor, _umbracoContextAccessor));
|
||||
return members.Select(m => PublishedMember.Create(m, GetContentType(m.ContentTypeId), preview, _publishedSnapshotAccessor, VariationContextAccessor));
|
||||
}
|
||||
|
||||
public XPathNavigator CreateNavigator()
|
||||
|
||||
@@ -22,9 +22,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
ContentNode contentNode,
|
||||
ContentData contentData,
|
||||
IPublishedSnapshotAccessor publishedSnapshotAccessor,
|
||||
IVariationContextAccessor variationContextAccessor,
|
||||
IUmbracoContextAccessor umbracoContextAccessor)
|
||||
: base(umbracoContextAccessor)
|
||||
IVariationContextAccessor variationContextAccessor)
|
||||
{
|
||||
_contentNode = contentNode ?? throw new ArgumentNullException(nameof(contentNode));
|
||||
ContentData = contentData ?? throw new ArgumentNullException(nameof(contentData));
|
||||
@@ -69,7 +67,6 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
// used when cloning in ContentNode
|
||||
public PublishedContent(ContentNode contentNode, PublishedContent origin)
|
||||
: base(origin.UmbracoContextAccessor)
|
||||
{
|
||||
_contentNode = contentNode;
|
||||
_publishedSnapshotAccessor = origin._publishedSnapshotAccessor;
|
||||
@@ -86,10 +83,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
}
|
||||
|
||||
// clone for previewing as draft a published content that is published and has no draft
|
||||
private PublishedContent(
|
||||
PublishedContent origin,
|
||||
IUmbracoContextAccessor umbracoContextAccessor)
|
||||
: base(umbracoContextAccessor)
|
||||
private PublishedContent(PublishedContent origin)
|
||||
{
|
||||
_publishedSnapshotAccessor = origin._publishedSnapshotAccessor;
|
||||
VariationContextAccessor = origin.VariationContextAccessor;
|
||||
@@ -406,8 +400,8 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
return this;
|
||||
|
||||
var cache = GetAppropriateCache();
|
||||
if (cache == null) return new PublishedContent(this, UmbracoContextAccessor).CreateModel();
|
||||
return (IPublishedContent)cache.Get(AsPreviewingCacheKey, () => new PublishedContent(this, UmbracoContextAccessor).CreateModel());
|
||||
if (cache == null) return new PublishedContent(this).CreateModel();
|
||||
return (IPublishedContent)cache.Get(AsPreviewingCacheKey, () => new PublishedContent(this).CreateModel());
|
||||
}
|
||||
|
||||
// used by Navigable.Source,...
|
||||
|
||||
@@ -20,10 +20,8 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
ContentNode contentNode,
|
||||
ContentData contentData,
|
||||
IPublishedSnapshotAccessor publishedSnapshotAccessor,
|
||||
IVariationContextAccessor variationContextAccessor,
|
||||
IUmbracoContextAccessor umbracoContextAccessor
|
||||
)
|
||||
: base(contentNode, contentData, publishedSnapshotAccessor, variationContextAccessor, umbracoContextAccessor)
|
||||
IVariationContextAccessor variationContextAccessor)
|
||||
: base(contentNode, contentData, publishedSnapshotAccessor, variationContextAccessor)
|
||||
{
|
||||
_member = member;
|
||||
}
|
||||
@@ -33,8 +31,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
IPublishedContentType contentType,
|
||||
bool previewing,
|
||||
IPublishedSnapshotAccessor publishedSnapshotAccessor,
|
||||
IVariationContextAccessor variationContextAccessor,
|
||||
IUmbracoContextAccessor umbracoContextAccessor)
|
||||
IVariationContextAccessor variationContextAccessor)
|
||||
{
|
||||
var d = new ContentData
|
||||
{
|
||||
@@ -50,7 +47,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
member.Level, member.Path, member.SortOrder,
|
||||
member.ParentId,
|
||||
member.CreateDate, member.CreatorId);
|
||||
return new PublishedMember(member, n, d, publishedSnapshotAccessor, variationContextAccessor, umbracoContextAccessor).CreateModel();
|
||||
return new PublishedMember(member, n, d, publishedSnapshotAccessor, variationContextAccessor).CreateModel();
|
||||
}
|
||||
|
||||
private static Dictionary<string, PropertyData[]> GetPropertyValues(IPublishedContentType contentType, IMember member)
|
||||
|
||||
@@ -34,7 +34,6 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
{
|
||||
private readonly ServiceContext _serviceContext;
|
||||
private readonly IPublishedContentTypeFactory _publishedContentTypeFactory;
|
||||
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
|
||||
private readonly IScopeProvider _scopeProvider;
|
||||
private readonly IDataSource _dataSource;
|
||||
private readonly ILogger _logger;
|
||||
@@ -42,7 +41,6 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
private readonly IMediaRepository _mediaRepository;
|
||||
private readonly IMemberRepository _memberRepository;
|
||||
private readonly IGlobalSettings _globalSettings;
|
||||
private readonly ISiteDomainHelper _siteDomainHelper;
|
||||
private readonly IEntityXmlSerializer _entitySerializer;
|
||||
private readonly IDefaultCultureAccessor _defaultCultureAccessor;
|
||||
private readonly UrlSegmentProviderCollection _urlSegmentProviders;
|
||||
@@ -83,11 +81,10 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
public PublishedSnapshotService(Options options, IMainDom mainDom, IRuntimeState runtime,
|
||||
ServiceContext serviceContext, IPublishedContentTypeFactory publishedContentTypeFactory, IdkMap idkMap,
|
||||
IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor,
|
||||
IUmbracoContextAccessor umbracoContextAccessor, ILogger logger, IScopeProvider scopeProvider,
|
||||
IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor, ILogger logger, IScopeProvider scopeProvider,
|
||||
IDocumentRepository documentRepository, IMediaRepository mediaRepository, IMemberRepository memberRepository,
|
||||
IDefaultCultureAccessor defaultCultureAccessor,
|
||||
IDataSource dataSource, IGlobalSettings globalSettings, ISiteDomainHelper siteDomainHelper,
|
||||
IDataSource dataSource, IGlobalSettings globalSettings,
|
||||
IEntityXmlSerializer entitySerializer, IPublishedModelFactory publishedModelFactory,
|
||||
UrlSegmentProviderCollection urlSegmentProviders)
|
||||
: base(publishedSnapshotAccessor, variationContextAccessor)
|
||||
@@ -97,7 +94,6 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
_serviceContext = serviceContext;
|
||||
_publishedContentTypeFactory = publishedContentTypeFactory;
|
||||
_umbracoContextAccessor = umbracoContextAccessor;
|
||||
_dataSource = dataSource;
|
||||
_logger = logger;
|
||||
_scopeProvider = scopeProvider;
|
||||
@@ -106,7 +102,6 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
_memberRepository = memberRepository;
|
||||
_defaultCultureAccessor = defaultCultureAccessor;
|
||||
_globalSettings = globalSettings;
|
||||
_siteDomainHelper = siteDomainHelper;
|
||||
_urlSegmentProviders = urlSegmentProviders;
|
||||
|
||||
// we need an Xml serializer here so that the member cache can support XPath,
|
||||
@@ -156,13 +151,13 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
// stores are created with a db so they can write to it, but they do not read from it,
|
||||
// stores need to be populated, happens in OnResolutionFrozen which uses _localDbExists to
|
||||
// figure out whether it can read the databases or it should populate them from sql
|
||||
_contentStore = new ContentStore(publishedSnapshotAccessor, variationContextAccessor, _umbracoContextAccessor, logger, _localContentDb);
|
||||
_mediaStore = new ContentStore(publishedSnapshotAccessor, variationContextAccessor, _umbracoContextAccessor, logger, _localMediaDb);
|
||||
_contentStore = new ContentStore(publishedSnapshotAccessor, variationContextAccessor, logger, _localContentDb);
|
||||
_mediaStore = new ContentStore(publishedSnapshotAccessor, variationContextAccessor, logger, _localMediaDb);
|
||||
}
|
||||
else
|
||||
{
|
||||
_contentStore = new ContentStore(publishedSnapshotAccessor, variationContextAccessor, _umbracoContextAccessor, logger);
|
||||
_mediaStore = new ContentStore(publishedSnapshotAccessor, variationContextAccessor, _umbracoContextAccessor, logger);
|
||||
_contentStore = new ContentStore(publishedSnapshotAccessor, variationContextAccessor, logger);
|
||||
_mediaStore = new ContentStore(publishedSnapshotAccessor, variationContextAccessor, logger);
|
||||
}
|
||||
|
||||
_domainStore = new SnapDictionary<int, Domain>();
|
||||
@@ -1077,7 +1072,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
{
|
||||
ContentCache = new ContentCache(previewDefault, contentSnap, snapshotCache, elementsCache, domainCache, _globalSettings),
|
||||
MediaCache = new MediaCache(previewDefault, mediaSnap, snapshotCache, elementsCache),
|
||||
MemberCache = new MemberCache(previewDefault, snapshotCache, _serviceContext.MemberService, memberTypeCache, PublishedSnapshotAccessor, VariationContextAccessor, _umbracoContextAccessor, _entitySerializer),
|
||||
MemberCache = new MemberCache(previewDefault, snapshotCache, _serviceContext.MemberService, memberTypeCache, PublishedSnapshotAccessor, VariationContextAccessor, _entitySerializer),
|
||||
DomainCache = domainCache,
|
||||
SnapshotCache = snapshotCache,
|
||||
ElementsCache = elementsCache
|
||||
|
||||
@@ -21,9 +21,7 @@ namespace Umbraco.Web.PublishedCache
|
||||
|
||||
public PublishedMember(
|
||||
IMember member,
|
||||
IPublishedContentType publishedMemberType,
|
||||
IUmbracoContextAccessor umbracoContextAccessor)
|
||||
:base(umbracoContextAccessor)
|
||||
IPublishedContentType publishedMemberType)
|
||||
{
|
||||
_member = member ?? throw new ArgumentNullException(nameof(member));
|
||||
_membershipUser = member;
|
||||
|
||||
@@ -1208,5 +1208,43 @@ namespace Umbraco.Web
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Url
|
||||
|
||||
/// <summary>
|
||||
/// Gets the url of the content item.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>If the content item is a document, then this method returns the url of the
|
||||
/// document. If it is a media, then this methods return the media url for the
|
||||
/// 'umbracoFile' property. Use the MediaUrl() method to get the media url for other
|
||||
/// properties.</para>
|
||||
/// <para>The value of this property is contextual. It depends on the 'current' request uri,
|
||||
/// if any. In addition, when the content type is multi-lingual, this is the url for the
|
||||
/// specified culture. Otherwise, it is the invariant url.</para>
|
||||
/// </remarks>
|
||||
public static string Url(this IPublishedContent content, string culture = null, UrlMode mode = UrlMode.Auto)
|
||||
{
|
||||
var umbracoContext = Composing.Current.UmbracoContext;
|
||||
|
||||
if (umbracoContext == null)
|
||||
throw new InvalidOperationException("Cannot resolve a Url when Current.UmbracoContext is null.");
|
||||
if (umbracoContext.UrlProvider == null)
|
||||
throw new InvalidOperationException("Cannot resolve a Url when Current.UmbracoContext.UrlProvider is null.");
|
||||
|
||||
switch (content.ContentType.ItemType)
|
||||
{
|
||||
case PublishedItemType.Content:
|
||||
return umbracoContext.UrlProvider.GetUrl(content, mode, culture);
|
||||
|
||||
case PublishedItemType.Media:
|
||||
return umbracoContext.UrlProvider.GetMediaUrl(content, mode, culture, Constants.Conventions.Media.File);
|
||||
|
||||
default:
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,9 +209,9 @@ namespace Umbraco.Web
|
||||
var umbracoContext = Composing.Current.UmbracoContext;
|
||||
|
||||
if (umbracoContext == null)
|
||||
throw new InvalidOperationException("Cannot resolve a Url for a content item when Current.UmbracoContext is null.");
|
||||
throw new InvalidOperationException("Cannot resolve a Url when Current.UmbracoContext is null.");
|
||||
if (umbracoContext.UrlProvider == null)
|
||||
throw new InvalidOperationException("Cannot resolve a Url for a content item when Current.UmbracoContext.UrlProvider is null.");
|
||||
throw new InvalidOperationException("Cannot resolve a Url when Current.UmbracoContext.UrlProvider is null.");
|
||||
|
||||
return umbracoContext.UrlProvider.GetMediaUrl(content, mode, culture, propertyAlias);
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace Umbraco.Web.Routing
|
||||
string url;
|
||||
try
|
||||
{
|
||||
url = umbracoContext.UrlProvider.GetUrl(content.Id, culture);
|
||||
url = umbracoContext.UrlProvider.GetUrl(content.Id, culture: culture);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user