Cleanup
This commit is contained in:
@@ -57,8 +57,6 @@ namespace Umbraco.Cms.Core.PropertyEditors.ValueConverters
|
||||
var publishedSnapshot = _publishedSnapshotAccessor.GetRequiredPublishedSnapshot();
|
||||
if (inter is int id)
|
||||
{
|
||||
|
||||
|
||||
content = publishedSnapshot.Content.GetById(id);
|
||||
if (content != null)
|
||||
return content;
|
||||
|
||||
@@ -55,8 +55,6 @@ namespace Umbraco.Cms.Core.PropertyEditors.ValueConverters
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
IPublishedContent member;
|
||||
var publishedSnapshot = _publishedSnapshotAccessor.GetRequiredPublishedSnapshot();
|
||||
if (source is int id)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace Umbraco.Cms.Core.PublishedCache
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides access to a TryGetPublishedSnapshot bool method that will return true if the "current" <see cref="IPublishedSnapshot"/>. is not null
|
||||
/// Provides access to a TryGetPublishedSnapshot bool method that will return true if the "current" <see cref="IPublishedSnapshot"/> is not null.
|
||||
/// </summary>
|
||||
public interface IPublishedSnapshotAccessor
|
||||
{
|
||||
|
||||
@@ -42,9 +42,15 @@ namespace Umbraco.Cms.Core.Templates
|
||||
/// <returns></returns>
|
||||
public string EnsureInternalLinks(string text, bool preview)
|
||||
{
|
||||
var umbracoContext = _umbracoContextAccessor.GetRequiredUmbracoContext();
|
||||
if (!_umbracoContextAccessor.TryGetUmbracoContext(out var umbracoContext))
|
||||
{
|
||||
throw new InvalidOperationException("Could not parse internal links, there is no current UmbracoContext");
|
||||
}
|
||||
|
||||
if (!preview)
|
||||
{
|
||||
return EnsureInternalLinks(text);
|
||||
}
|
||||
|
||||
using (umbracoContext.ForcedPreview(preview)) // force for URL provider
|
||||
{
|
||||
|
||||
@@ -15,16 +15,24 @@ namespace Umbraco.Cms.Core.Web
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="UmbracoContext"/> object.
|
||||
/// Tries to get the <see cref="UmbracoContext"/> object.
|
||||
/// </summary>
|
||||
///
|
||||
public bool TryGetUmbracoContext(out IUmbracoContext umbracoContext)
|
||||
{
|
||||
umbracoContext = Value;
|
||||
|
||||
return umbracoContext is not null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the current <see cref="UmbracoContext"/> object.
|
||||
/// </summary>
|
||||
public void Clear() => Value = null;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the <see cref="UmbracoContext"/> object.
|
||||
/// </summary>
|
||||
/// <param name="umbracoContext"></param>
|
||||
public void Set(IUmbracoContext umbracoContext) => Value = umbracoContext;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
namespace Umbraco.Cms.Core.Web
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides access to a TryGetUmbracoContext bool method that will return true if the "current" <see cref="IUmbracoContext"/>. is not null.
|
||||
/// Provides a Clear() method that will clear the current UmbracoContext.
|
||||
/// Provides a Set() method that til set the current UmbracoContext.
|
||||
/// Provides access to a TryGetUmbracoContext bool method that will return true if the "current" <see cref="IUmbracoContext"/> is not null.
|
||||
/// Provides a Clear() method that will clear the current <see cref="UmbracoContext"/> object.
|
||||
/// Provides a Set() method that til set the current <see cref="UmbracoContext"/> object.
|
||||
/// </summary>
|
||||
public interface IUmbracoContextAccessor
|
||||
{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Umbraco.Cms.Infrastructure;
|
||||
|
||||
namespace Umbraco.Cms.Core
|
||||
{
|
||||
@@ -9,12 +8,12 @@ namespace Umbraco.Cms.Core
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
|
||||
public PublishedContentQueryAccessor(IServiceProvider serviceProvider) => _serviceProvider = serviceProvider;
|
||||
|
||||
public bool TryGetValue(out IPublishedContentQuery publishedContentQuery)
|
||||
{
|
||||
publishedContentQuery = _serviceProvider.GetRequiredService<IPublishedContentQuery>();
|
||||
|
||||
return publishedContentQuery is not null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,14 @@ namespace Umbraco.Cms.Infrastructure.PublishedCache
|
||||
_publishedModelFactory = publishedModelFactory;
|
||||
}
|
||||
|
||||
protected PublishedSnapshot CurrentPublishedSnapshot { get { _publishedSnapshotAccessor.TryGetPublishedSnapshot(out var publishedSnapshot); return (PublishedSnapshot)publishedSnapshot; } }
|
||||
protected PublishedSnapshot CurrentPublishedSnapshot
|
||||
{
|
||||
get
|
||||
{
|
||||
_publishedSnapshotAccessor.TryGetPublishedSnapshot(out var publishedSnapshot);
|
||||
return (PublishedSnapshot)publishedSnapshot;
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: These aren't used within this object but are made available internally to improve the IdKey lookup performance
|
||||
// when nucache is enabled.
|
||||
@@ -880,9 +887,12 @@ namespace Umbraco.Cms.Infrastructure.PublishedCache
|
||||
break;
|
||||
case DomainChangeTypes.Refresh:
|
||||
var domain = _serviceContext.DomainService.GetById(payload.Id);
|
||||
if (domain == null) continue;
|
||||
if (domain.RootContentId.HasValue == false) continue; // anomaly
|
||||
if (domain.LanguageIsoCode.IsNullOrWhiteSpace()) continue; // anomaly
|
||||
if (domain == null)
|
||||
continue;
|
||||
if (domain.RootContentId.HasValue == false)
|
||||
continue; // anomaly
|
||||
if (domain.LanguageIsoCode.IsNullOrWhiteSpace())
|
||||
continue; // anomaly
|
||||
var culture = domain.LanguageIsoCode;
|
||||
_domainStore.SetLocked(domain.Id, new Domain(domain.Id, domain.DomainName, domain.RootContentId.Value, culture, domain.IsWildcard));
|
||||
break;
|
||||
|
||||
@@ -3,6 +3,5 @@ namespace Umbraco.Cms.Web.Common
|
||||
public interface IUmbracoHelperAccessor
|
||||
{
|
||||
bool TryGetUmbracoHelper(out UmbracoHelper umbracoHelper);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user