Skip to content

Commit b7def10

Browse files
committed
Updating changelog to renamed cmdlet name
1 parent b8d750e commit b7def10

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
6666
- Added `Copy-PnPPage`, `Move-PnPPage` and `Get-PnPPageCopyProgress` cmdlets to allow for copying and moving site pages between sites [#4806](https://github.com/pnp/powershell/pull/4806)
6767
- Added `Get-PnPBrandCenterConfig` to retrieve the configuration of the Brand Center on the tenant [#4830](https://github.com/pnp/powershell/pull/4830)
6868
- Added `Get-PnPBrandCenterFont` to retrieve the available fonts from the various Brand Centers [#4830](https://github.com/pnp/powershell/pull/4830)
69-
- Added `Set-PnPBrandCenterFont` to apply the specified font from the Brand Center to the current site [#4830](https://github.com/pnp/powershell/pull/4830)
69+
- Added `Use-PnPBrandCenterFont` to apply the specified font from the Brand Center to the current site [#4830](https://github.com/pnp/powershell/pull/4830)
7070
- Added `Add-PnPBrandCenterFont` to upload a font to the tenant Brand Center [#4830](https://github.com/pnp/powershell/pull/4830)
7171

7272
### Changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using System.Collections;
2+
using System.Management.Automation;
3+
using Microsoft.SharePoint.Client;
4+
using PnP.PowerShell.Commands.Base.Completers;
5+
using PnP.PowerShell.Commands.Base.PipeBinds;
6+
using PnP.PowerShell.Commands.Utilities;
7+
8+
namespace PnP.PowerShell.Commands.Files
9+
{
10+
[Cmdlet(VerbsCommon.Set, "PnPBrandCenterFont")]
11+
[OutputType(typeof(void))]
12+
public class SetBrandCenterFont : PnPWebCmdlet
13+
{
14+
[Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true)]
15+
[ArgumentCompleter(typeof(BrandCenterFontCompleter))]
16+
public BrandCenterFontPipeBind Identity { get; set; }
17+
18+
[Parameter(Mandatory = true)]
19+
public bool Visible;
20+
21+
protected override void ExecuteCmdlet()
22+
{
23+
var webUrl = CurrentWeb.EnsureProperty(w => w.Url);
24+
25+
var brandCenterConfig = BrandCenterUtility.GetBrandCenterConfiguration(this, ClientContext);
26+
if (brandCenterConfig == null || !brandCenterConfig.IsBrandCenterSiteFeatureEnabled || string.IsNullOrEmpty(brandCenterConfig.SiteUrl))
27+
{
28+
throw new PSArgumentException("Brand Center is not enabled for this tenant");
29+
}
30+
31+
LogDebug($"Connecting to the Brand Center site at {brandCenterConfig.SiteUrl}");
32+
using var brandCenterContext = Connection.CloneContext(brandCenterConfig.SiteUrl);
33+
var font = Identity.GetFont(this, ClientContext, webUrl);
34+
35+
LogDebug($"Retrieving the Brand Center font library with ID {brandCenterConfig.BrandFontLibraryId}");
36+
var brandCenterFontLibrary = brandCenterContext.Web.GetListById(brandCenterConfig.BrandFontLibraryId);
37+
brandCenterContext.Load(brandCenterFontLibrary, l => l.RootFolder);
38+
brandCenterContext.ExecuteQueryRetry();
39+
40+
LogDebug($"Uploading the font to the Brand Center font library root folder at {brandCenterFontLibrary.RootFolder.ServerRelativeUrl}");
41+
var file = brandCenterFontLibrary.RootFolder.UploadFile(System.IO.Path.GetFileName(Path), Path, true);
42+
43+
if (ParameterSpecified(nameof(Visible)) && Visible.HasValue)
44+
{
45+
LogDebug($"Setting the font visibility to {Visible.Value}");
46+
ListItemHelper.SetFieldValues(file.ListItemAllFields, new Hashtable { { "_SPFontVisible", Visible.Value ? "True" : "False" } }, this);
47+
file.ListItemAllFields.UpdateOverwriteVersion();
48+
}
49+
50+
brandCenterContext.Load(file);
51+
brandCenterContext.ExecuteQueryRetry();
52+
53+
LogDebug("Font uploaded successfully");
54+
WriteObject(file);
55+
}
56+
}
57+
}

0 commit comments

Comments
 (0)