Using Modules and Extensions

Lynicon is a highly modular system. This means that basic CMS functionality like publishing content and caching can be switched out if it is not needed, making the CMS run faster and reducing clutter.  It also means that modules have great scope to change how Lynicon functions.

Modules are fairly simple to build and can be a convenient way of setting up code to handle global events, or code which adds or modifies the Lynicon UI.

Modules are included in an application by initialisation code as below:

services.AddLynicon(options =>
                options.UseConfiguration(Configuration.GetSection("Lynicon:Core"))
                    .UseTypeSetup(col =>
                        {
                            col.SetupType<Cafe>(new ObjectCollator(col.System),
                                new ObjectRepository(col.System, new KenticoCloudDataSourceFactory(col.System, new Guid("7319e896-6ed4-496b-a0f0-372bbe2d17b5"))));
                            col.SetupType<AlternateUrlsContent>();
                            col.SetupType<SpecsDocContent>(new ObjectCollator(col.System),
                                new ObjectRepository(col.System, new ElasticDataSourceFactory(col.System, (t, iv) => "test")));
                        })
                    .UseModule<CoreModule>()
                    .UseModule<ContentSchemaModule>()
                    .UseModule<LyniconBaseCommands>(.. licence key ..)
                        .UseModule<FullCache>(Configuration.GetSection("Lynicon:Base:Cache"))
                        .UseModule<SoftDelete>((Func<Type, bool>)(t => !(new Type[] { typeof(User), typeof(AlternateUrlsContent), typeof(SpecsDocContent) }.Contains(t))))
                        .UseModule<Publishing>((Func<Type, bool>)(t => !(new Type[] { typeof(User), typeof(AlternateUrlsContent), typeof(SpecsDocContent) }.Contains(t))))
                        .UseModule<References>()
                        .UseModule<UrlListModule>()
                        .UseModule<Auditing>(TimeSpan.FromDays(30))
                        .UseModule<Lynicon.Base.Modules.Search>((Func<Type, bool>)(t => t == typeof(Cafe)), (Func<Type, string>)(t => "main"), new ElasticSearchEngine())
                        .UseModule<Sitemap>(
                            (Func<Type, bool>)(t => t != typeof(User)),
                            (Func<Summary, bool>)(s => true))
                            )
                .AddLyniconIdentity();

The .UseModule method is used to add a module to configuration. It takes as its generic argument the type of the module class. Arguments can be passed to the module, unfortunately Intellisense cannot be used with these so please consult the documentation for the module. Generally the first argument is a function taking a content type and returning whether the module should act on data of that type.