From ead7741ee2397541719b613750c920272df8d586 Mon Sep 17 00:00:00 2001 From: Andy Butland Date: Thu, 16 Nov 2023 06:33:36 +0100 Subject: [PATCH] Updated rich text parser interfaces to support context cache. (#15220) --- src/Umbraco.Core/Deploy/IImageSourceParser.cs | 25 ++++++++++++ src/Umbraco.Core/Deploy/ILocalLinkParser.cs | 28 ++++++++++++++ src/Umbraco.Core/Deploy/IMacroParser.cs | 38 +++++++++++++++++++ 3 files changed, 91 insertions(+) diff --git a/src/Umbraco.Core/Deploy/IImageSourceParser.cs b/src/Umbraco.Core/Deploy/IImageSourceParser.cs index 0180ec0b3d..cbbaa6bc9a 100644 --- a/src/Umbraco.Core/Deploy/IImageSourceParser.cs +++ b/src/Umbraco.Core/Deploy/IImageSourceParser.cs @@ -12,13 +12,38 @@ public interface IImageSourceParser /// A list of dependencies. /// The parsed value. /// Turns src="/media/..." into src="umb://media/..." and adds the corresponding udi to the dependencies. + [Obsolete("Please use the overload taking all parameters. This method will be removed in Umbraco 14.")] string ToArtifact(string value, ICollection dependencies); + /// + /// Parses an Umbraco property value and produces an artifact property value. + /// + /// The property value. + /// A list of dependencies. + /// The context cache. + /// The parsed value. + /// Turns src="/media/..." into src="umb://media/..." and adds the corresponding udi to the dependencies. +#pragma warning disable CS0618 // Type or member is obsolete + string ToArtifact(string value, ICollection dependencies, IContextCache contextCache) => ToArtifact(value, dependencies); +#pragma warning restore CS0618 // Type or member is obsolete + /// /// Parses an artifact property value and produces an Umbraco property value. /// /// The artifact property value. /// The parsed value. /// Turns umb://media/... into /media/.... + [Obsolete("Please use the overload taking all parameters. This method will be removed in Umbraco 14.")] string FromArtifact(string value); + + /// + /// Parses an artifact property value and produces an Umbraco property value. + /// + /// The artifact property value. + /// The context cache. + /// The parsed value. + /// Turns umb://media/... into /media/.... +#pragma warning disable CS0618 // Type or member is obsolete + string FromArtifact(string value, IContextCache contextCache) => FromArtifact(value); +#pragma warning restore CS0618 // Type or member is obsolete } diff --git a/src/Umbraco.Core/Deploy/ILocalLinkParser.cs b/src/Umbraco.Core/Deploy/ILocalLinkParser.cs index 7ec3fff0fa..d84bf35af1 100644 --- a/src/Umbraco.Core/Deploy/ILocalLinkParser.cs +++ b/src/Umbraco.Core/Deploy/ILocalLinkParser.cs @@ -15,13 +15,41 @@ public interface ILocalLinkParser /// Turns {{localLink:1234}} into {{localLink:umb://{type}/{id}}} and adds the corresponding udi to the /// dependencies. /// + [Obsolete("Please use the overload taking all parameters. This method will be removed in Umbraco 14.")] string ToArtifact(string value, ICollection dependencies); + /// + /// Parses an Umbraco property value and produces an artifact property value. + /// + /// The property value. + /// A list of dependencies. + /// The context cache. + /// The parsed value. + /// + /// Turns {{localLink:1234}} into {{localLink:umb://{type}/{id}}} and adds the corresponding udi to the + /// dependencies. + /// +#pragma warning disable CS0618 // Type or member is obsolete + string ToArtifact(string value, ICollection dependencies, IContextCache contextCache) => ToArtifact(value, dependencies); +#pragma warning restore CS0618 // Type or member is obsolete + /// /// Parses an artifact property value and produces an Umbraco property value. /// /// The artifact property value. /// The parsed value. /// Turns {{localLink:umb://{type}/{id}}} into {{localLink:1234}}. + [Obsolete("Please use the overload taking all parameters. This method will be removed in Umbraco 14.")] string FromArtifact(string value); + + /// + /// Parses an artifact property value and produces an Umbraco property value. + /// + /// The artifact property value. + /// The context cache. + /// The parsed value. + /// Turns {{localLink:umb://{type}/{id}}} into {{localLink:1234}}. +#pragma warning disable CS0618 // Type or member is obsolete + string FromArtifact(string value, IContextCache contextCache) => FromArtifact(value); +#pragma warning restore CS0618 // Type or member is obsolete } diff --git a/src/Umbraco.Core/Deploy/IMacroParser.cs b/src/Umbraco.Core/Deploy/IMacroParser.cs index fed9dcc3af..17f06992d5 100644 --- a/src/Umbraco.Core/Deploy/IMacroParser.cs +++ b/src/Umbraco.Core/Deploy/IMacroParser.cs @@ -8,15 +8,38 @@ public interface IMacroParser /// Property value. /// A list of dependencies. /// Parsed value. + [Obsolete("Please use the overload taking all parameters. This method will be removed in Umbraco 14.")] string ToArtifact(string value, ICollection dependencies); + /// + /// Parses an Umbraco property value and produces an artifact property value. + /// + /// Property value. + /// A list of dependencies. + /// The context cache. + /// Parsed value. +#pragma warning disable CS0618 // Type or member is obsolete + string ToArtifact(string value, ICollection dependencies, IContextCache contextCache) => ToArtifact(value, dependencies); +#pragma warning restore CS0618 // Type or member is obsolete + /// /// Parses an artifact property value and produces an Umbraco property value. /// /// Artifact property value. /// Parsed value. + [Obsolete("Please use the overload taking all parameters. This method will be removed in Umbraco 14.")] string FromArtifact(string value); + /// + /// Parses an artifact property value and produces an Umbraco property value. + /// + /// Artifact property value. + /// The context cache. + /// Parsed value. +#pragma warning disable CS0618 // Type or member is obsolete + string FromArtifact(string value, IContextCache contextCache) => FromArtifact(value); +#pragma warning restore CS0618 // Type or member is obsolete + /// /// Tries to replace the value of the attribute/parameter with a value containing a converted identifier. /// @@ -25,5 +48,20 @@ public interface IMacroParser /// Collection to add dependencies to when performing ToArtifact /// Indicates which action is being performed (to or from artifact) /// Value with converted identifiers + [Obsolete("Please use the overload taking all parameters. This method will be removed in Umbraco 14.")] string ReplaceAttributeValue(string value, string editorAlias, ICollection dependencies, Direction direction); + + /// + /// Tries to replace the value of the attribute/parameter with a value containing a converted identifier. + /// + /// Value to attempt to convert + /// Alias of the editor used for the parameter + /// Collection to add dependencies to when performing ToArtifact + /// Indicates which action is being performed (to or from artifact) + /// The context cache. + /// Value with converted identifiers + string ReplaceAttributeValue(string value, string editorAlias, ICollection dependencies, Direction direction, IContextCache contextCache) +#pragma warning disable CS0618 // Type or member is obsolete + => ReplaceAttributeValue(value, editorAlias, dependencies, direction); +#pragma warning restore CS0618 // Type or member is obsolete }