Class CodeFileController
Inheritance
Namespace: Umbraco.Cms.Web.BackOffice.Controllers
Assembly: Umbraco.Web.BackOffice.dll
Syntax
[PluginController("UmbracoApi")]
[Authorize(Policy = "SectionAccessSettings")]
public class CodeFileController : BackOfficeNotificationsController, IUmbracoFeature, IDiscoverable
Constructors
View SourceCodeFileController(IHostingEnvironment, FileSystems, IFileService, IBackOfficeSecurityAccessor, ILocalizedTextService, IUmbracoMapper, IShortStringHelper, IOptionsSnapshot<GlobalSettings>)
Declaration
public CodeFileController(IHostingEnvironment hostingEnvironment, FileSystems fileSystems, IFileService fileService, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, ILocalizedTextService localizedTextService, IUmbracoMapper umbracoMapper, IShortStringHelper shortStringHelper, IOptionsSnapshot<GlobalSettings> globalSettings)
Parameters
Type | Name | Description |
---|---|---|
IHostingEnvironment | hostingEnvironment | |
FileSystems | fileSystems | |
IFileService | fileService | |
IBackOfficeSecurityAccessor | backOfficeSecurityAccessor | |
ILocalizedTextService | localizedTextService | |
IUmbracoMapper | umbracoMapper | |
IShortStringHelper | shortStringHelper | |
Microsoft.Extensions.Options.IOptionsSnapshot<GlobalSettings> | globalSettings |
CodeFileController(IHostingEnvironment, FileSystems, IFileService, IBackOfficeSecurityAccessor, ILocalizedTextService, IUmbracoMapper, IShortStringHelper, IOptionsSnapshot<GlobalSettings>, PartialViewSnippetCollection, PartialViewMacroSnippetCollection)
Declaration
[ActivatorUtilitiesConstructor]
public CodeFileController(IHostingEnvironment hostingEnvironment, FileSystems fileSystems, IFileService fileService, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, ILocalizedTextService localizedTextService, IUmbracoMapper umbracoMapper, IShortStringHelper shortStringHelper, IOptionsSnapshot<GlobalSettings> globalSettings, PartialViewSnippetCollection partialViewSnippetCollection, PartialViewMacroSnippetCollection partialViewMacroSnippetCollection)
Parameters
Type | Name | Description |
---|---|---|
IHostingEnvironment | hostingEnvironment | |
FileSystems | fileSystems | |
IFileService | fileService | |
IBackOfficeSecurityAccessor | backOfficeSecurityAccessor | |
ILocalizedTextService | localizedTextService | |
IUmbracoMapper | umbracoMapper | |
IShortStringHelper | shortStringHelper | |
Microsoft.Extensions.Options.IOptionsSnapshot<GlobalSettings> | globalSettings | |
PartialViewSnippetCollection | partialViewSnippetCollection | |
PartialViewMacroSnippetCollection | partialViewMacroSnippetCollection |
Methods
View SourceDelete(String, String)
Used to delete a specific file from disk via the FileService
Declaration
[HttpDelete]
[HttpPost]
public IActionResult Delete(string type, string virtualPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | type | This is a string but will be 'scripts' 'partialViews', 'partialViewMacros' or 'stylesheets' |
System.String | virtualPath | The filename or URL encoded path of the file to delete |
Returns
Type | Description |
---|---|
Microsoft.AspNetCore.Mvc.IActionResult | Will return a simple 200 if file deletion succeeds |
GetByPath(String, String)
Used to get a specific file from disk via the FileService
Declaration
public ActionResult<CodeFileDisplay> GetByPath(string type, string virtualPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | type | This is a string but will be 'scripts' 'partialViews', 'partialViewMacros' or 'stylesheets' |
System.String | virtualPath | The filename or URL encoded path of the file to open |
Returns
Type | Description |
---|---|
Microsoft.AspNetCore.Mvc.ActionResult<CodeFileDisplay> | The file and its contents from the virtualPath |
GetScaffold(String, String, String)
Used to scaffold the json object for the editors for 'scripts', 'partialViews', 'partialViewMacros' and 'stylesheets'
Declaration
public ActionResult<CodeFileDisplay> GetScaffold(string type, string id, string snippetName = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | type | This is a string but will be 'scripts' 'partialViews', 'partialViewMacros' or 'stylesheets' |
System.String | id | |
System.String | snippetName |
Returns
Type | Description |
---|---|
Microsoft.AspNetCore.Mvc.ActionResult<CodeFileDisplay> |
GetSnippets(String)
Used to get a list of available templates/snippets to base a new Partial View or Partial View Macro from
Declaration
public ActionResult<IEnumerable<SnippetDisplay>> GetSnippets(string type)
Parameters
Type | Name | Description |
---|---|---|
System.String | type | This is a string but will be 'partialViews', 'partialViewMacros' |
Returns
Type | Description |
---|---|
Microsoft.AspNetCore.Mvc.ActionResult<IEnumerable<SnippetDisplay>> | Returns a list of SnippetDisplay if a correct type is sent |
PostCreate(String, CodeFileDisplay)
Used to create a brand new file
Declaration
public ActionResult<CodeFileDisplay> PostCreate(string type, CodeFileDisplay display)
Parameters
Type | Name | Description |
---|---|---|
System.String | type | This is a string but will be 'scripts' 'partialViews', 'partialViewMacros' |
CodeFileDisplay | display |
Returns
Type | Description |
---|---|
Microsoft.AspNetCore.Mvc.ActionResult<CodeFileDisplay> | Will return a simple 200 if file creation succeeds |
PostCreateContainer(String, String, String)
Used to create a container/folder in 'partialViews', 'partialViewMacros', 'scripts' or 'stylesheets'
Declaration
[HttpPost]
public ActionResult<CodeFileDisplay> PostCreateContainer(string type, string parentId, string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | type | 'partialViews', 'partialViewMacros' or 'scripts' |
System.String | parentId | The virtual path of the parent. |
System.String | name | The name of the container/folder |
Returns
Type | Description |
---|---|
Microsoft.AspNetCore.Mvc.ActionResult<CodeFileDisplay> |
PostExtractStylesheetRules(CodeFileController.StylesheetData)
Extracts "umbraco style rules" from a style sheet
Declaration
public StylesheetRule[] PostExtractStylesheetRules(CodeFileController.StylesheetData data)
Parameters
Type | Name | Description |
---|---|---|
CodeFileController.StylesheetData | data | The style sheet data |
Returns
Type | Description |
---|---|
StylesheetRule[] | The style rules |
PostInterpolateStylesheetRules(CodeFileController.StylesheetData)
Creates a style sheet from CSS and style rules
Declaration
public string PostInterpolateStylesheetRules(CodeFileController.StylesheetData data)
Parameters
Type | Name | Description |
---|---|---|
CodeFileController.StylesheetData | data | The style sheet data |
Returns
Type | Description |
---|---|
System.String | The style sheet combined from the CSS and the rules |
Remarks
Any "umbraco style rules" in the CSS will be removed and replaced with the rules passed in
PostSave(CodeFileDisplay)
Used to create or update a 'partialview', 'partialviewmacro', 'script' or 'stylesheets' file
Declaration
public ActionResult<CodeFileDisplay> PostSave(CodeFileDisplay display)
Parameters
Type | Name | Description |
---|---|---|
CodeFileDisplay | display |
Returns
Type | Description |
---|---|
Microsoft.AspNetCore.Mvc.ActionResult<CodeFileDisplay> | The updated CodeFileDisplay model |