Skip to content

Commit

Permalink
AddWordPressShortcodesFromViews() - not implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubmisek committed Jan 23, 2023
1 parent 01ce70f commit 3cd2629
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
34 changes: 34 additions & 0 deletions PeachPied.WordPress.AspNetCore/Internal/ViewsAsShortcodesPlugin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.ViewComponents;
using PeachPied.WordPress.Standard;

namespace PeachPied.WordPress.AspNetCore.Internal
{
internal sealed class ViewsAsShortcodesPlugin : IWpPlugin, IWpPluginProvider // TODO
{
readonly IViewComponentDescriptorCollectionProvider _viewsProvider;

public ViewsAsShortcodesPlugin(IViewComponentDescriptorCollectionProvider viewsProvider)
{
_viewsProvider = viewsProvider;
}

ValueTask IWpPlugin.ConfigureAsync(WpApp app, CancellationToken token)
{
if (_viewsProvider != null)
{
foreach (var item in _viewsProvider.ViewComponents.Items)
{

}
}

return ValueTask.CompletedTask;
}

IEnumerable<IWpPlugin> IWpPluginProvider.GetPlugins(IServiceProvider provider, string wpRootPath) => new[] { this };
}
}
22 changes: 22 additions & 0 deletions PeachPied.WordPress.AspNetCore/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.Extensions.DependencyInjection;
using PeachPied.WordPress.AspNetCore;
using PeachPied.WordPress.AspNetCore.Internal;
using PeachPied.WordPress.Standard;
using System;

Expand Down Expand Up @@ -32,5 +33,26 @@ public static IServiceCollection AddWordPress(this IServiceCollection services,
//
return services;
}

///// <summary>
///// Registers all shared views as WordPress shortcodes correspondingly.
///// </summary>
///// <remarks>Same as configuring WordPress with <see cref="PeachPied.WordPress.AspNetCore.WpAppExtension.RegisterPartialViewAsShortcode"/> for each shared view.</remarks>
//public static IServiceCollection AddWordPressShortcodesFromViews(this IServiceCollection services)
//{
// if (services == null)
// {
// throw new ArgumentNullException(nameof(services));
// }

// services.Add(new ServiceDescriptor(
// typeof(IWpPluginProvider),
// typeof(ViewsAsShortcodesPlugin),
// ServiceLifetime.Transient
// ));

// //
// return services;
//}
}
}

0 comments on commit 3cd2629

Please sign in to comment.