Skip to content

Commit 5f37736

Browse files
authored
Merge pull request #6919 from umbraco/ui-builder-composers
Added info on usage of Composer...
2 parents 27f7184 + 5ad8416 commit 5f37736

File tree

2 files changed

+57
-14
lines changed

2 files changed

+57
-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 in the `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: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,21 @@
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.
8+
9+
{% hint style="info" %}
10+
By default, Umbraco UI Builder uses a database for data storage. However, you can configure this using a custom [Repository](../advanced/repositories.md) class instead.
11+
{% endhint %}
812

913
## Setting Up the Database
1014

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.
15+
Umbraco UI Builder uses PetaPoco as its default persistence layer.
16+
17+
In this section, you will create a `Person` table to store data.
1218

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.
19+
To create a `Person` table, run the following script in SQL Server Management Studio (SSMS).
1420

1521
```sql
1622
CREATE TABLE [Person] (
@@ -24,16 +30,16 @@ CREATE TABLE [Person] (
2430
);
2531
```
2632

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

2935
## Setting Up the Model
3036

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

3339
To create a Model:
3440

3541
1. Create a new folder called **Models** in your project.
36-
2. Create a new class file called `Person.cs`.
42+
2. Add a new class file called `Person.cs`.
3743
3. Add the following code:
3844

3945
```csharp
@@ -59,6 +65,14 @@ public class Person
5965

6066
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.
6167

68+
{% hint style="info" %}
69+
You can configure Umbraco UI Builder either through a Composer or by using the `AddUIBuilder` extension method in `Program.cs`.
70+
{% endhint %}
71+
72+
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.
73+
74+
### Configuring via `Program.cs`
75+
6276
1. Open the `Program.cs` file in your project.
6377
2. Locate the `CreateUmbracoBuilder()` method.
6478
3. Add `AddUIBuilder` before `AddComposers()`.
@@ -75,7 +89,9 @@ builder.CreateUmbracoBuilder()
7589
.Build();
7690
```
7791

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

8096
```csharp
8197
...

0 commit comments

Comments
 (0)