Skip to content
This repository was archived by the owner on Feb 10, 2024. It is now read-only.

Commit 704118f

Browse files
committed
Refactored the SurfaceControllerExists
as UmbracoHelper was being not used nor required.
1 parent fe106f0 commit 704118f

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

src/Our.Umbraco.DocTypeGridEditor/Our.Umbraco.DocTypeGridEditor.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@
237237
<Compile Include="Extensions\ContentTypeServiceExtensions.cs" />
238238
<Compile Include="Web\Controllers\DocTypeGridEditorSurfaceController.cs" />
239239
<Compile Include="Web\Extensions\HtmlHelperExtensions.cs" />
240-
<Compile Include="Web\Extensions\UmbracoHelperExtensions.cs" />
240+
<Compile Include="Web\Helpers\SurfaceControllerHelper.cs" />
241241
<Compile Include="Web\Mvc\DefaultDocTypeGridEditorSurfaceControllerResolver.cs" />
242242
</ItemGroup>
243243
<ItemGroup>

src/Our.Umbraco.DocTypeGridEditor/Web/Extensions/HtmlHelperExtensions.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Web.Mvc;
33
using System.Web.Mvc.Html;
44
using Our.Umbraco.DocTypeGridEditor.Extensions;
5+
using Our.Umbraco.DocTypeGridEditor.Web.Helpers;
56
using Our.Umbraco.DocTypeGridEditor.Web.Mvc;
67
using Umbraco.Core;
78
using Umbraco.Core.Models;
@@ -11,7 +12,8 @@ namespace Our.Umbraco.DocTypeGridEditor.Web.Extensions
1112
{
1213
public static class HtmlHelperExtensions
1314
{
14-
public static HtmlString RenderDocTypeGridEditorItem(this HtmlHelper helper,
15+
public static HtmlString RenderDocTypeGridEditorItem(
16+
this HtmlHelper helper,
1517
IPublishedContent content,
1618
string editorAlias = "",
1719
string viewPath = "",
@@ -28,10 +30,8 @@ public static HtmlString RenderDocTypeGridEditorItem(this HtmlHelper helper,
2830
if (!string.IsNullOrWhiteSpace(previewViewPath))
2931
previewViewPath = previewViewPath.TrimEnd('/') + "/";
3032

31-
var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
32-
3333
// Try looking for surface controller with action named after the editor alias
34-
if (!editorAlias.IsNullOrWhiteSpace() && umbracoHelper.SurfaceControllerExists(controllerName, editorAlias, true))
34+
if (!editorAlias.IsNullOrWhiteSpace() && SurfaceControllerHelper.SurfaceControllerExists(controllerName, editorAlias, true))
3535
{
3636
return helper.Action(editorAlias, controllerName, new
3737
{
@@ -42,7 +42,7 @@ public static HtmlString RenderDocTypeGridEditorItem(this HtmlHelper helper,
4242
}
4343

4444
// Try looking for surface controller with action named after the doc type alias alias
45-
if (umbracoHelper.SurfaceControllerExists(controllerName, content.DocumentTypeAlias, true))
45+
if (SurfaceControllerHelper.SurfaceControllerExists(controllerName, content.DocumentTypeAlias, true))
4646
{
4747
return helper.Action(content.DocumentTypeAlias, controllerName, new
4848
{
@@ -59,7 +59,7 @@ public static HtmlString RenderDocTypeGridEditorItem(this HtmlHelper helper,
5959
var defaultControllerName = defaultController.Name.Substring(0, defaultController.Name.LastIndexOf("Controller"));
6060

6161
// Try looking for an action named after the editor alias
62-
if (!editorAlias.IsNullOrWhiteSpace() && umbracoHelper.SurfaceControllerExists(defaultControllerName, editorAlias, true))
62+
if (!editorAlias.IsNullOrWhiteSpace() && SurfaceControllerHelper.SurfaceControllerExists(defaultControllerName, editorAlias, true))
6363
{
6464
return helper.Action(editorAlias, defaultControllerName, new
6565
{
@@ -70,7 +70,7 @@ public static HtmlString RenderDocTypeGridEditorItem(this HtmlHelper helper,
7070
}
7171

7272
// Try looking for a doc type alias action
73-
if (umbracoHelper.SurfaceControllerExists(defaultControllerName, content.DocumentTypeAlias, true))
73+
if (SurfaceControllerHelper.SurfaceControllerExists(defaultControllerName, content.DocumentTypeAlias, true))
7474
{
7575
return helper.Action(content.DocumentTypeAlias, defaultControllerName, new
7676
{

src/Our.Umbraco.DocTypeGridEditor/Web/Extensions/UmbracoHelperExtensions.cs renamed to src/Our.Umbraco.DocTypeGridEditor/Web/Helpers/SurfaceControllerHelper.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
using Umbraco.Web;
99
using Umbraco.Web.Mvc;
1010

11-
namespace Our.Umbraco.DocTypeGridEditor.Web.Extensions
11+
namespace Our.Umbraco.DocTypeGridEditor.Web.Helpers
1212
{
13-
internal static class UmbracoHelperExtensions
13+
internal static class SurfaceControllerHelper
1414
{
15-
public static bool SurfaceControllerExists(this UmbracoHelper helper, string controllerName, string actionName = "Index")
15+
public static bool SurfaceControllerExists(string controllerName, string actionName = "Index")
1616
{
17-
using (var timer = DisposableTimer.DebugDuration<UmbracoHelper>(string.Format("SurfaceControllerExists ({0}, {1})", controllerName, actionName)))
17+
using (var timer = DisposableTimer.DebugDuration<Bootstrap>(string.Format("SurfaceControllerExists ({0}, {1})", controllerName, actionName)))
1818
{
1919
// Setup dummy route data
2020
var rd = new RouteData();
@@ -64,14 +64,14 @@ public static bool SurfaceControllerExists(this UmbracoHelper helper, string con
6464
}
6565
}
6666

67-
public static bool SurfaceControllerExists(this UmbracoHelper helper, string name, string actionName = "Index", bool cacheResult = true)
67+
public static bool SurfaceControllerExists(string name, string actionName = "Index", bool cacheResult = true)
6868
{
6969
if (!cacheResult)
70-
return SurfaceControllerExists(helper, name, actionName);
70+
return SurfaceControllerExists(name, actionName);
7171

7272
return (bool)ApplicationContext.Current.ApplicationCache.RuntimeCache.GetCacheItem(
73-
string.Join("_", new[] { "Our.Umbraco.Mortar.Web.Extensions.UmbracoHelperExtensions.SurfaceControllerExists", name, actionName }),
74-
() => SurfaceControllerExists(helper, name, actionName));
73+
string.Join("_", new[] { "Our.Umbraco.DocTypeGridEditor.Web.Helpers.SurfaceControllerHelper.SurfaceControllerExists", name, actionName }),
74+
() => SurfaceControllerExists(name, actionName));
7575
}
7676
}
7777
}

0 commit comments

Comments
 (0)