Skip to content

Commit 4c29ea1

Browse files
committed
Added usage of Composer
1 parent b9a621b commit 4c29ea1

File tree

2 files changed

+49
-14
lines changed

2 files changed

+49
-14
lines changed

15/umbraco-ui-builder/getting-started/configuration.md

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,39 @@
11
---
2-
description: Learn how to configure Umbraco UI Builder using the extension method.
2+
description: Learn how to configure Umbraco UI Builder in your project using two different approaches.
33
---
44

55
# Configuration
66

7-
You can configure Umbraco UI Builder using the `AddUIBuilder` extension method in `Program.cs`.
7+
You can configure Umbraco UI Builder either via a Composer or the `AddUIBuilder` extension method in `Program.cs`.
88

9-
## Using `AddUIBuilder`
9+
## Option 1: Configuring via a Composer
10+
11+
A Composer is a common approach for registering and configuring services in Umbraco during application startup.
12+
13+
To configure Umbraco UI Builder via a Composer:
14+
15+
1. Create a file called `UIBuilderComposer.cs` in your project.
16+
2. Implement the `IComposer` interface and add the configuration inside the `Compose` method:
17+
18+
```csharp
19+
using Umbraco.Cms.Core.Composing;
20+
using Umbraco.UIBuilder.Extensions;
21+
22+
public class UIBuilderComposer : IComposer
23+
{
24+
public void Compose(IUmbracoBuilder builder)
25+
{
26+
builder.AddUIBuilder(cfg =>
27+
{
28+
// Apply your configuration here
29+
});
30+
}
31+
}
32+
```
33+
34+
## Option 2: Configuring via `Program.cs`
35+
36+
You can also configure Umbraco UI Builder directly in `Program.cs` using the `AddUIBuilder` extension method.
1037

1138
To configure Umbraco UI Builder:
1239

@@ -26,8 +53,8 @@ builder.CreateUmbracoBuilder()
2653
.Build();
2754
```
2855

29-
{% hint style="info" %}
30-
If you want an example configuration, see the **Configure Umbraco UI Builder** section in the [Creating your First Integration](../guides/creating-your-first-integration.md) article.
31-
{% endhint %}
56+
## Example Configuration
57+
58+
For a complete sample configuration, see the [Creating your First Integration](../guides/creating-your-first-integration.md) article.
3259

3360
The `AddUIBuilder` method accepts a delegate function, allowing you to configure your solution using fluent APIs.

15/umbraco-ui-builder/guides/creating-your-first-integration.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22
description: Creating your first integration with Umbraco UI Builder.
33
---
44

5-
# Creating your first integration
5+
# Creating Your First Umbraco UI Builder Integration
66

7-
In this guide, you will find the necessary steps needed for a basic implementation using Umbraco UI Builder to manage a single custom database table.
7+
This guide walks you through a basic implementation of Umbraco UI Builder to manage a custom database table.
88

99
## Setting Up the Database
1010

11-
Out of the box, Umbraco UI Builder works using PetaPoco as the persistence layer, as this is what ships with Umbraco. If you prefer, it is possible to use a custom [Repository](../advanced/repositories.md). However, for getting started, it is expected that you are using this default strategy.
11+
Umbraco UI Builder uses PetaPoco as its default persistence layer. You can use a custom [Repository](../advanced/repositories.md), but this guide assumes the default approach.
1212

13-
In this section, let's create a `Person` table to store data. Run the following script in SQL Server Management Studio (SSMS) to create the `Person` table.
13+
In this section, let's create a `Person` table to store data.
14+
15+
To create a `Person` table, run the following script in SQL Server Management Studio (SSMS).
1416

1517
```sql
1618
CREATE TABLE [Person] (
@@ -24,16 +26,16 @@ CREATE TABLE [Person] (
2426
);
2527
```
2628

27-
This script creates a table for storing people’s details. You might want to populate it with some dummy data for testing.
29+
This script creates a table for storing people’s details. You may want to populate it with some dummy data for testing.
2830

2931
## Setting Up the Model
3032

31-
With the database table set up, create the associated Poco model in the project.
33+
With the database table created, define the `Person` model in your project.
3234

3335
To create a Model:
3436

3537
1. Create a new folder called **Models** in your project.
36-
2. Create a new class file called `Person.cs`.
38+
2. Add a new class file called `Person.cs`.
3739
3. Add the following code:
3840

3941
```csharp
@@ -59,6 +61,10 @@ public class Person
5961

6062
With the database and model set up, it is time to configure Umbraco UI Builder to work with the `Person` model. This will allow you to manage `Person` entities from the Umbraco backoffice.
6163

64+
You can choose to configure Umbraco UI Builder either through a Composer or by using the `AddUIBuilder` extension method in `Program.cs`. The following steps cover the `Program.cs` approach. For more details, including configuring via a Composer, see the the [Configuration](../getting-started/configuration.md) article.
65+
66+
### Configuring via `Program.cs`
67+
6268
1. Open the `Program.cs` file in your project.
6369
2. Locate the `CreateUmbracoBuilder()` method.
6470
3. Add `AddUIBuilder` before `AddComposers()`.
@@ -75,7 +81,9 @@ builder.CreateUmbracoBuilder()
7581
.Build();
7682
```
7783

78-
For this guide, the following configuration is used:
84+
### Example Configuration
85+
86+
Here’s an example configuration defining a section, a list view, and an editor for managing `Person` entities:
7987

8088
```csharp
8189
...

0 commit comments

Comments
 (0)