Skip to content

Commit

Permalink
Added so manager init is performed when blocks are created from the m…
Browse files Browse the repository at this point in the history
…anager. Fixes #1420
  • Loading branch information
tidyui committed Dec 29, 2020
1 parent 110f55c commit 516c0da
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion core/Piranha.Manager/Services/ContentTypeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public async Task<AsyncResult<BlockModel>> CreateBlockAsync(string type)

if (blockType != null)
{
var block = (Block)(await _factory.CreateBlockAsync(type));
var block = (Block)(await _factory.CreateBlockAsync(type, true));

if (block is BlockGroup)
{
Expand Down
5 changes: 3 additions & 2 deletions core/Piranha/Services/ContentFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ public Task<object> CreateDynamicRegionAsync(ContentTypeBase type, string region
/// Creates and initializes a new block of the specified type.
/// </summary>
/// <param name="typeName">The type name</param>
/// <param name="managerInit">If manager initialization should be performed</param>
/// <returns>The new block</returns>
public async Task<object> CreateBlockAsync(string typeName)
public async Task<object> CreateBlockAsync(string typeName, bool managerInit = false)
{
var blockType = App.Blocks.GetByType(typeName);

Expand All @@ -95,7 +96,7 @@ public async Task<object> CreateBlockAsync(string typeName)
if (typeof(Extend.IField).IsAssignableFrom(prop.PropertyType))
{
var field = Activator.CreateInstance(prop.PropertyType);
await InitFieldAsync(scope, field, false).ConfigureAwait(false);
await InitFieldAsync(scope, field, managerInit).ConfigureAwait(false);
prop.SetValue(block, field);
}
}
Expand Down
3 changes: 2 additions & 1 deletion core/Piranha/Services/IContentFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ public interface IContentFactory
/// Creates and initializes a new block of the specified type.
/// </summary>
/// <param name="typeName">The type name</param>
/// <param name="managerInit">If manager initialization should be performed</param>
/// <returns>The new block</returns>
Task<object> CreateBlockAsync(string typeName);
Task<object> CreateBlockAsync(string typeName, bool managerInit = false);

/// <summary>
/// Initializes the given model.
Expand Down

0 comments on commit 516c0da

Please sign in to comment.