Skip to content

Commit

Permalink
Added experimental feature to disable the expansion of properties.
Browse files Browse the repository at this point in the history
This comes into play if you want to prevent items from getting Automatic properties.
  • Loading branch information
michaellwest committed May 8, 2020
1 parent 7453ba8 commit ced8a96
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Spe/Core/Data/DisablePropertyExpander.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Sitecore.Common;

namespace Spe.Core.Data
{
public class DisablePropertyExpander : Switcher<bool, DisablePropertyExpander>
{
public DisablePropertyExpander() : base(true) { }
}
}
4 changes: 4 additions & 0 deletions src/Spe/Core/Extensions/ItemShellExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using Sitecore.Common;
using Sitecore.Data;
using Sitecore.Data.Events;
using Sitecore.Data.Fields;
using Sitecore.Data.Items;
using Sitecore.Diagnostics;
using Sitecore.Events;
using Sitecore.Resources.Media;
using Spe.Core.Data;
using Spe.Core.Settings;

namespace Spe.Core.Extensions
Expand All @@ -34,6 +36,8 @@ internal static PSObject GetPsObject(SessionState provider, Item item)
{
var psObject = PSObject.AsPSObject(item);

if (Switcher<bool, DisablePropertyExpander>.CurrentValue) return psObject;

Dictionary<ID, string> propertySet;
if (AllPropertySets.ContainsKey(item.TemplateID))
{
Expand Down
1 change: 1 addition & 0 deletions src/Spe/Spe.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@
<Compile Include="Commands\Presentation\AddPlaceholderSettingCommand.cs" />
<Compile Include="Commands\Presentation\NewPlaceholderSettingCommand.cs" />
<Compile Include="Commands\Security\Accounts\BaseSecurityCommand.cs" />
<Compile Include="Core\Data\DisablePropertyExpander.cs" />
<Compile Include="Core\Extensions\CustomFieldAccessor.cs" />
<Compile Include="Core\Extensions\ExpressionExtensions.cs" />
<Compile Include="Core\Extensions\EnumerableExtensions.cs" />
Expand Down

0 comments on commit ced8a96

Please sign in to comment.