-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
BasicContentPickerItem.cs
76 lines (64 loc) · 2.55 KB
/
BasicContentPickerItem.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using Nikcio.UHeadless.Base.Properties.EditorsValues.ContentPicker.Commands;
using Nikcio.UHeadless.Base.Properties.EditorsValues.ContentPicker.Models;
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Extensions;
namespace Nikcio.UHeadless.Base.Basics.EditorsValues.ContentPicker.Models;
/// <summary>
/// Represents a content picker item
/// </summary>
[GraphQLDescription("Represents a content picker item.")]
public class BasicContentPickerItem : ContentPickerItem
{
/// <summary>
/// Gets the url segment of the content item
/// </summary>
[GraphQLDescription("Gets the url segment of the content item.")]
public virtual string? UrlSegment => Content?.UrlSegment(VariationContextAccessor, Culture);
/// <summary>
/// Gets the url of a content item
/// </summary>
[GraphQLDescription("Gets the url of a content item.")]
public virtual string Url => Content.Url(Culture, UrlMode.Default);
/// <summary>
/// Gets the absolute url of a content item
/// </summary>
[GraphQLDescription("Gets the absolute url of a content item.")]
public virtual string AbsoluteUrl => Content.Url(Culture, UrlMode.Absolute);
/// <summary>
/// Gets the name of a content item
/// </summary>
[GraphQLDescription("Gets the name of a content item.")]
public virtual string? Name => Content?.Name(VariationContextAccessor, Culture);
/// <summary>
/// Gets the id of a content item
/// </summary>
[GraphQLDescription("Gets the id of a content item.")]
public virtual int Id => Content.Id;
/// <summary>
/// Gets the key of a content item
/// </summary>
[GraphQLDescription("Gets the key of a content item.")]
public virtual Guid Key => Content.Key;
/// <summary>
/// The <see cref="IPublishedContent"/>
/// </summary>
[GraphQLIgnore]
protected virtual IPublishedContent Content { get; set; }
/// <summary>
/// The variation context accessor
/// </summary>
[GraphQLIgnore]
protected virtual IVariationContextAccessor VariationContextAccessor { get; set; }
/// <summary>
/// The culture
/// </summary>
[GraphQLIgnore]
protected virtual string? Culture { get; set; }
/// <inheritdoc/>
public BasicContentPickerItem(CreateContentPickerItem createContentPickerItem) : base(createContentPickerItem)
{
ArgumentNullException.ThrowIfNull(createContentPickerItem);
Content = createContentPickerItem.PublishedContent;
VariationContextAccessor = createContentPickerItem.VariationContextAccessor;
}
}