Skip to content

Commit b5b5559

Browse files
authored
Merge pull request #6555 from erikjanwestendorp/update-itagquery
Porting old Umbraco API Controller [Querying > ITagQuery]
2 parents 2bdc8b4 + 895ffa8 commit b5b5559

File tree

4 files changed

+36
-42
lines changed

4 files changed

+36
-42
lines changed

10/umbraco-cms/reference/querying/itagquery.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: "Working with tags in Umbraco"
77

88
# ITagQuery
99

10-
The `ITagQuery` interface is your primary way to work with tags in Umbraco, the interface allows you to get the various tags like content tags and media tags, as well as getting content by tag, for instance getting all content nodes with the "Umbraco" tag.
10+
The `ITagQuery` interface is your primary way to work with tags in Umbraco. This interface allows you to get different tags, such as content tags and media tags. It also lets you retrieve content by tag, for instance, getting all content nodes with the "Umbraco" tag.
1111

1212
## How to reference ITagQuery
1313

@@ -49,7 +49,7 @@ namespace UmbracoHelperDocs.Controllers
4949
```
5050

5151
{% hint style="warning" %}
52-
`ITagQuery` is a scoped service, meaning that it should only be injected into scoped or transient services, for more information see the official [Microsoft Documentation](https://docs.microsoft.com/en-us/dotnet/core/extensions/dependency-injection#scoped)
52+
`ITagQuery` is a scoped service, meaning that it should only be injected into scoped or transient services. For more information see the official [Microsoft Documentation](https://docs.microsoft.com/en-us/dotnet/core/extensions/dependency-injection#scoped)
5353
{% endhint %}
5454

5555
## Examples
@@ -58,7 +58,7 @@ All examples are from a view using the injection shown above, but working with t
5858

5959
### GetAllContentTags([string tagGroup])
6060

61-
Get a collection of tags used by content items on the site, you can optionally pass in a group name to only list tags belonging to a specific tag group
61+
Get a collection of tags used by content items on the site. Optionally, you can pass in a group name to only list tags belonging to a specific tag group
6262

6363
```csharp
6464
@{
@@ -69,7 +69,7 @@ Get a collection of tags used by content items on the site, you can optionally p
6969

7070
### GetAllMediaTags([string tagGroup])
7171

72-
Get a collection of tags used by media items on the site, you can optionally pass in a group name to only list tags belonging to a specific tag group
72+
Get a collection of tags used by media items on the site. Optionally, you can pass in a group name to only list tags belonging to a specific tag group
7373

7474
```csharp
7575
@{
@@ -80,7 +80,7 @@ Get a collection of tags used by media items on the site, you can optionally pas
8080

8181
### GetAllMemberTags([string tagGroup])
8282

83-
Get a collection of tags used by members on the site, you can optionally pass in a group name to only list tags belonging to a specific tag group
83+
Get a collection of tags used by members on the site. Optionally, you can pass in a group name to only list tags belonging to a specific tag group
8484

8585
```csharp
8686
@{
@@ -91,7 +91,7 @@ Get a collection of tags used by members on the site, you can optionally pass in
9191

9292
### GetAllTags([string tagGroup])
9393

94-
Get a collection of tags used on the site, you can optionally pass in a group name to only list tags belonging to a specific tag group
94+
Get a collection of tags used on the site. Optionally, you can pass in a group name to only list tags belonging to a specific tag group
9595

9696
```csharp
9797
@{
@@ -152,7 +152,7 @@ Get a collection of tags by entity id (queries content, media and members), and
152152

153153
### GetTagsForProperty(int contentId, string propertyTypeAlias, [string tagGroup])
154154

155-
Get a collection of tags assigned to a property of an entity (queries content, media and members), and you can optionally filter by tag group as well
155+
Get a collection of tags assigned to a property of an entity (queries content, media and members). Optionally, you can filter by tag group as well
156156

157157
```csharp
158158
@{

13/umbraco-cms/reference/querying/itagquery.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Working with tags in Umbraco
44

55
# ITagQuery
66

7-
The `ITagQuery` interface is your primary way to work with tags in Umbraco, the interface allows you to get the various tags like content tags and media tags, as well as getting content by tag, for instance getting all content nodes with the "Umbraco" tag.
7+
The `ITagQuery` interface is your primary way to work with tags in Umbraco. This interface allows you to get different tags, such as content tags and media tags. It also lets you retrieve content by tag, for instance, getting all content nodes with the "Umbraco" tag.
88

99
## How to reference ITagQuery
1010

@@ -45,7 +45,7 @@ public class TagApiController : UmbracoApiController
4545
```
4646

4747
{% hint style="warning" %}
48-
`ITagQuery` is a scoped service, meaning that it should only be injected into scoped or transient services, for more information see the official [Microsoft Documentation](https://docs.microsoft.com/en-us/dotnet/core/extensions/dependency-injection#scoped)
48+
`ITagQuery` is a scoped service, meaning that it should only be injected into scoped or transient services. For more information see the official [Microsoft Documentation](https://docs.microsoft.com/en-us/dotnet/core/extensions/dependency-injection#scoped)
4949
{% endhint %}
5050

5151
## Examples
@@ -54,7 +54,7 @@ All examples are from a view using the injection shown above, but working with t
5454

5555
### GetAllContentTags(\[string tagGroup])
5656

57-
Get a collection of tags used by content items on the site, you can optionally pass in a group name to only list tags belonging to a specific tag group
57+
Get a collection of tags used by content items on the site. Optionally, you can pass in a group name to only list tags belonging to a specific tag group
5858

5959
```csharp
6060
@{
@@ -65,7 +65,7 @@ Get a collection of tags used by content items on the site, you can optionally p
6565

6666
### GetAllMediaTags(\[string tagGroup])
6767

68-
Get a collection of tags used by media items on the site, you can optionally pass in a group name to only list tags belonging to a specific tag group
68+
Get a collection of tags used by media items on the site. Optionally, you can pass in a group name to only list tags belonging to a specific tag group
6969

7070
```csharp
7171
@{
@@ -76,7 +76,7 @@ Get a collection of tags used by media items on the site, you can optionally pas
7676

7777
### GetAllMemberTags(\[string tagGroup])
7878

79-
Get a collection of tags used by members on the site, you can optionally pass in a group name to only list tags belonging to a specific tag group
79+
Get a collection of tags used by members on the site. Optionally, you can pass in a group name to only list tags belonging to a specific tag group
8080

8181
```csharp
8282
@{
@@ -87,7 +87,7 @@ Get a collection of tags used by members on the site, you can optionally pass in
8787

8888
### GetAllTags(\[string tagGroup])
8989

90-
Get a collection of tags used on the site, you can optionally pass in a group name to only list tags belonging to a specific tag group
90+
Get a collection of tags used on the site. Optionally, you can pass in a group name to only list tags belonging to a specific tag group
9191

9292
```csharp
9393
@{
@@ -148,7 +148,7 @@ Get a collection of tags by entity id (queries content, media and members), and
148148

149149
### GetTagsForProperty(int contentId, string propertyTypeAlias, \[string tagGroup])
150150

151-
Get a collection of tags assigned to a property of an entity (queries content, media and members), and you can optionally filter by tag group as well
151+
Get a collection of tags assigned to a property of an entity (queries content, media and members). Optionally, you can filter by tag group as well
152152

153153
```csharp
154154
@{

14/umbraco-cms/reference/querying/itagquery.md

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Working with tags in Umbraco
44

55
# ITagQuery
66

7-
The `ITagQuery` interface is your primary way to work with tags in Umbraco, the interface allows you to get the various tags like content tags and media tags, as well as getting content by tag, for instance getting all content nodes with the "Umbraco" tag.
7+
The `ITagQuery` interface is your primary way to work with tags in Umbraco. This interface allows you to get different tags, such as content tags and media tags. It also lets you retrieve content by tag, for instance, getting all content nodes with the "Umbraco" tag.
88

99
## How to reference ITagQuery
1010

@@ -18,21 +18,17 @@ After this you can use `_tagQuery` to access the `ITagQuery`.
1818

1919
If you're using it in controllers, you can inject it into the constructor like so:
2020

21-
{% hint style="warning" %}
22-
The example below uses UmbracoApiController which is obsolete in Umbraco 14 and will be removed in Umbraco 15.
23-
{% endhint %}
24-
2521
```csharp
2622
using System.Collections.Generic;
2723
using System.Linq;
2824
using Microsoft.AspNetCore.Mvc;
2925
using Umbraco.Cms.Core.PublishedCache;
30-
using Umbraco.Cms.Web.Common.Controllers;
3126

3227
namespace UmbracoHelperDocs.Controllers;
3328

34-
[Route("tags/[action]")]
35-
public class TagApiController : UmbracoApiController
29+
[ApiController]
30+
[Route("/umbraco/api/tags")]
31+
public class TagApiController : Controller
3632
{
3733
private readonly ITagQuery _tagQuery;
3834

@@ -41,6 +37,7 @@ public class TagApiController : UmbracoApiController
4137
_tagQuery = tagQuery;
4238
}
4339

40+
[HttpGet("getmediatags")]
4441
public ActionResult<IEnumerable<string>> GetMediaTags()
4542
{
4643
return _tagQuery.GetAllMediaTags().Select(tag => tag.Text).ToList();
@@ -49,7 +46,7 @@ public class TagApiController : UmbracoApiController
4946
```
5047

5148
{% hint style="warning" %}
52-
`ITagQuery` is a scoped service, meaning that it should only be injected into scoped or transient services, for more information see the official [Microsoft Documentation](https://docs.microsoft.com/en-us/dotnet/core/extensions/dependency-injection#scoped)
49+
`ITagQuery` is a scoped service, meaning that it should only be injected into scoped or transient services. For more information see the official [Microsoft Documentation](https://docs.microsoft.com/en-us/dotnet/core/extensions/dependency-injection#scoped)
5350
{% endhint %}
5451

5552
## Examples
@@ -58,7 +55,7 @@ All examples are from a view using the injection shown above, but working with t
5855

5956
### GetAllContentTags(\[string tagGroup])
6057

61-
Get a collection of tags used by content items on the site, you can optionally pass in a group name to only list tags belonging to a specific tag group
58+
Get a collection of tags used by content items on the site. Optionally, you can pass in a group name to only list tags belonging to a specific tag group
6259

6360
```csharp
6461
@{
@@ -69,7 +66,7 @@ Get a collection of tags used by content items on the site, you can optionally p
6966

7067
### GetAllMediaTags(\[string tagGroup])
7168

72-
Get a collection of tags used by media items on the site, you can optionally pass in a group name to only list tags belonging to a specific tag group
69+
Get a collection of tags used by media items on the site. Optionally, you can pass in a group name to only list tags belonging to a specific tag group
7370

7471
```csharp
7572
@{
@@ -80,7 +77,7 @@ Get a collection of tags used by media items on the site, you can optionally pas
8077

8178
### GetAllMemberTags(\[string tagGroup])
8279

83-
Get a collection of tags used by members on the site, you can optionally pass in a group name to only list tags belonging to a specific tag group
80+
Get a collection of tags used by members on the site. Optionally, you can pass in a group name to only list tags belonging to a specific tag group
8481

8582
```csharp
8683
@{
@@ -91,7 +88,7 @@ Get a collection of tags used by members on the site, you can optionally pass in
9188

9289
### GetAllTags(\[string tagGroup])
9390

94-
Get a collection of tags used on the site, you can optionally pass in a group name to only list tags belonging to a specific tag group
91+
Get a collection of tags used on the site. Optionally, you can pass in a group name to only list tags belonging to a specific tag group
9592

9693
```csharp
9794
@{
@@ -152,7 +149,7 @@ Get a collection of tags by entity id (queries content, media and members), and
152149

153150
### GetTagsForProperty(int contentId, string propertyTypeAlias, \[string tagGroup])
154151

155-
Get a collection of tags assigned to a property of an entity (queries content, media and members), and you can optionally filter by tag group as well
152+
Get a collection of tags assigned to a property of an entity (queries content, media and members). Optionally, you can filter by tag group as well
156153

157154
```csharp
158155
@{

15/umbraco-cms/reference/querying/itagquery.md

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Working with tags in Umbraco
44

55
# ITagQuery
66

7-
The `ITagQuery` interface is your primary way to work with tags in Umbraco, the interface allows you to get the various tags like content tags and media tags, as well as getting content by tag, for instance getting all content nodes with the "Umbraco" tag.
7+
The `ITagQuery` interface is your primary way to work with tags in Umbraco. This interface allows you to get different tags, such as content tags and media tags. It also lets you retrieve content by tag, for instance, getting all content nodes with the "Umbraco" tag.
88

99
## How to reference ITagQuery
1010

@@ -18,21 +18,17 @@ After this you can use `_tagQuery` to access the `ITagQuery`.
1818

1919
If you're using it in controllers, you can inject it into the constructor like so:
2020

21-
{% hint style="warning" %}
22-
The example below uses UmbracoApiController which is obsolete in Umbraco 14 and will be removed in Umbraco 15.
23-
{% endhint %}
24-
2521
```csharp
2622
using System.Collections.Generic;
2723
using System.Linq;
2824
using Microsoft.AspNetCore.Mvc;
2925
using Umbraco.Cms.Core.PublishedCache;
30-
using Umbraco.Cms.Web.Common.Controllers;
3126

3227
namespace UmbracoHelperDocs.Controllers;
3328

34-
[Route("tags/[action]")]
35-
public class TagApiController : UmbracoApiController
29+
[ApiController]
30+
[Route("/umbraco/api/tags")]
31+
public class TagApiController : Controller
3632
{
3733
private readonly ITagQuery _tagQuery;
3834

@@ -41,6 +37,7 @@ public class TagApiController : UmbracoApiController
4137
_tagQuery = tagQuery;
4238
}
4339

40+
[HttpGet("getmediatags")]
4441
public ActionResult<IEnumerable<string>> GetMediaTags()
4542
{
4643
return _tagQuery.GetAllMediaTags().Select(tag => tag.Text).ToList();
@@ -49,7 +46,7 @@ public class TagApiController : UmbracoApiController
4946
```
5047

5148
{% hint style="warning" %}
52-
`ITagQuery` is a scoped service, meaning that it should only be injected into scoped or transient services, for more information see the official [Microsoft Documentation](https://docs.microsoft.com/en-us/dotnet/core/extensions/dependency-injection#scoped)
49+
`ITagQuery` is a scoped service, meaning that it should only be injected into scoped or transient services. For more information see the official [Microsoft Documentation](https://docs.microsoft.com/en-us/dotnet/core/extensions/dependency-injection#scoped)
5350
{% endhint %}
5451

5552
## Examples
@@ -58,7 +55,7 @@ All examples are from a view using the injection shown above, but working with t
5855

5956
### GetAllContentTags(\[string tagGroup])
6057

61-
Get a collection of tags used by content items on the site, you can optionally pass in a group name to only list tags belonging to a specific tag group
58+
Get a collection of tags used by content items on the site. Optionally, you can pass in a group name to only list tags belonging to a specific tag group
6259

6360
```csharp
6461
@{
@@ -69,7 +66,7 @@ Get a collection of tags used by content items on the site, you can optionally p
6966

7067
### GetAllMediaTags(\[string tagGroup])
7168

72-
Get a collection of tags used by media items on the site, you can optionally pass in a group name to only list tags belonging to a specific tag group
69+
Get a collection of tags used by media items on the site. Optionally, you can pass in a group name to only list tags belonging to a specific tag group
7370

7471
```csharp
7572
@{
@@ -80,7 +77,7 @@ Get a collection of tags used by media items on the site, you can optionally pas
8077

8178
### GetAllMemberTags(\[string tagGroup])
8279

83-
Get a collection of tags used by members on the site, you can optionally pass in a group name to only list tags belonging to a specific tag group
80+
Get a collection of tags used by members on the site. Optionally, you can pass in a group name to only list tags belonging to a specific tag group
8481

8582
```csharp
8683
@{
@@ -91,7 +88,7 @@ Get a collection of tags used by members on the site, you can optionally pass in
9188

9289
### GetAllTags(\[string tagGroup])
9390

94-
Get a collection of tags used on the site, you can optionally pass in a group name to only list tags belonging to a specific tag group
91+
Get a collection of tags used on the site. Optionally, you can pass in a group name to only list tags belonging to a specific tag group
9592

9693
```csharp
9794
@{
@@ -152,7 +149,7 @@ Get a collection of tags by entity id (queries content, media and members), and
152149

153150
### GetTagsForProperty(int contentId, string propertyTypeAlias, \[string tagGroup])
154151

155-
Get a collection of tags assigned to a property of an entity (queries content, media and members), and you can optionally filter by tag group as well
152+
Get a collection of tags assigned to a property of an entity (queries content, media and members). Optionally, you can filter by tag group as well
156153

157154
```csharp
158155
@{

0 commit comments

Comments
 (0)