Files
Umbraco-CMS/src/Umbraco.Web.BackOffice/ModelsBuilder/DisableModelsBuilderNotificationHandler.cs
Ronald Barendse dca4d0f167 Add runtime mode (BackofficeDevelopment, Development and Production) (#12631)
* Add runtime mode setting

* Only enable Razor runtime compilation in development modes

* Only enable ModelsBuilder generation in development modes

* Fix disabling ModelsBuilder controllers

* Add IRuntimeModeValidationService and IRuntimeModeValidator

* Add JITOptimizerValidator

* Add UmbracoApplicationUrlValidator

* Add UseHttpsValidator

* Add RuntimeMinificationValidator

* Add ModelsBuilderModeValidator

* Remove .NET 6 preview 1 fix for Razor runtime compilation

* Only allow InMemoryAuto in backoffice development mode

* Make runtime mode validators public, so they can be easily removed if required

* Add comment to highlight removing RazorCompileOnBuild, RazorCompileOnPublish and CopyRazorGenerateFilesToPublishDirectory when using ModelsMode InMemoryAuto

* Add documentation

* Update src/Umbraco.Web.Common/ModelsBuilder/NoopModelsBuilderDashboardProvider.cs

Co-authored-by: Ronald Barendse <ronald@barend.se>

Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
2022-07-01 08:48:05 +02:00

23 lines
933 B
C#

using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Features;
using Umbraco.Cms.Core.Notifications;
namespace Umbraco.Cms.Web.BackOffice.ModelsBuilder;
/// <summary>
/// Used in conjunction with <see cref="UmbracoBuilderExtensions.DisableModelsBuilderControllers"/>
/// </summary>
internal class DisableModelsBuilderNotificationHandler : INotificationHandler<UmbracoApplicationStartingNotification>
{
private readonly UmbracoFeatures _features;
public DisableModelsBuilderNotificationHandler(UmbracoFeatures features) => _features = features;
/// <summary>
/// Handles the <see cref="UmbracoApplicationStartingNotification" /> notification to disable MB controller features
/// </summary>
public void Handle(UmbracoApplicationStartingNotification notification) =>
// disable the embedded dashboard controller
_features.Disabled.Controllers.Add<ModelsBuilderDashboardController>();
}