Editors
Lynicon's editor system is a generic and adaptable way of providing editing of the data stored in the Data API. Essentially, a DataRoute processing a request looks up a function from DataDiverter.Instance (chosen by the type of data being requested) to decide based on a RouteContext and the content data whether the request should be diverted to a special controller. This controller (which will normally inherit from EditorController) creates a page with form elements which when posted back, are used to update the relevant content item via model binding.
Setting the Editor to use for a Route or Content Type
The default diverter diverts to DualFrameEditorController when a user has the Lynicon Editor role. This supports the standard page editor.
You can change this behaviour per route or per type. To change the diverter used for a DataRoute, do this:
routes.MapDataRoute<TestData>("testData", "testdata/{_0}", new { controller = "Test", action = "Data" }, null, null, DataDiverter.Instance.NullDivert);
In this example, a data route is set up for TestData type content. The constant standard diverter NullDivert is used which never diverts the request to an editor, so it will not be possible to edit the content when accessed via this route.
To change the diverter used for a content type in any route, do this:
services.AddLynicon(options => options.UseConfiguration(Configuration.GetSection("Lynicon:Core")) .UseTypeSetup(tsr => { ... tsr.SetupType(typeof(TestData), new BasicCollator(null), new BasicRepository(new CoreDataSourceFactory()), DataDiverter.Instance.NullDivert); }) );
In this example any DataRoute<T> where T is TestData will now use the NullDivert diverter. Note that this also sets up TestData to use a BasicCollator and BasicRepository - if you wish to keep the defaults, replace these parameters with null.