Class CodeFileController
- Namespace
- Umbraco.Cms.Web.BackOffice.Controllers
- Assembly
- Umbraco.Web.BackOffice.dll
[Authorize(Policy = "SectionAccessSettings")]
public class CodeFileController : BackOfficeNotificationsController
- Inheritance
-
CodeFileController
- Inherited Members
Constructors
CodeFileController(IHostingEnvironment, FileSystems, IFileService, IBackOfficeSecurityAccessor, ILocalizedTextService, IUmbracoMapper, IShortStringHelper, IOptionsSnapshot<GlobalSettings>)
[Obsolete("Use ctor will all params. Scheduled for removal in V12.")]
public CodeFileController(IHostingEnvironment hostingEnvironment, FileSystems fileSystems, IFileService fileService, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, ILocalizedTextService localizedTextService, IUmbracoMapper umbracoMapper, IShortStringHelper shortStringHelper, IOptionsSnapshot<GlobalSettings> globalSettings)
Parameters
hostingEnvironmentIHostingEnvironmentfileSystemsFileSystemsfileServiceIFileServicebackOfficeSecurityAccessorIBackOfficeSecurityAccessorlocalizedTextServiceILocalizedTextServiceumbracoMapperIUmbracoMappershortStringHelperIShortStringHelperglobalSettingsIOptionsSnapshot<GlobalSettings>
CodeFileController(IHostingEnvironment, FileSystems, IFileService, IBackOfficeSecurityAccessor, ILocalizedTextService, IUmbracoMapper, IShortStringHelper, IOptionsSnapshot<GlobalSettings>, PartialViewSnippetCollection, PartialViewMacroSnippetCollection)
[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
hostingEnvironmentIHostingEnvironmentfileSystemsFileSystemsfileServiceIFileServicebackOfficeSecurityAccessorIBackOfficeSecurityAccessorlocalizedTextServiceILocalizedTextServiceumbracoMapperIUmbracoMappershortStringHelperIShortStringHelperglobalSettingsIOptionsSnapshot<GlobalSettings>partialViewSnippetCollectionPartialViewSnippetCollectionpartialViewMacroSnippetCollectionPartialViewMacroSnippetCollection
Methods
Delete(string, string)
Used to delete a specific file from disk via the FileService
[HttpDelete]
[HttpPost]
public IActionResult Delete(string type, string virtualPath)
Parameters
typestringThis is a string but will be 'scripts' 'partialViews', 'partialViewMacros' or 'stylesheets'
virtualPathstringThe filename or URL encoded path of the file to delete
Returns
- IActionResult
Will return a simple 200 if file deletion succeeds
GetByPath(string, string)
Used to get a specific file from disk via the FileService
public ActionResult<CodeFileDisplay?> GetByPath(string type, string virtualPath)
Parameters
typestringThis is a string but will be 'scripts' 'partialViews', 'partialViewMacros' or 'stylesheets'
virtualPathstringThe filename or URL encoded path of the file to open
Returns
- 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'
public ActionResult<CodeFileDisplay?> GetScaffold(string type, string id, string? snippetName = null)
Parameters
typestringThis is a string but will be 'scripts' 'partialViews', 'partialViewMacros' or 'stylesheets'
idstringsnippetNamestring
Returns
- ActionResult<CodeFileDisplay>
GetSnippets(string)
Used to get a list of available templates/snippets to base a new Partial View or Partial View Macro from
public ActionResult<IEnumerable<SnippetDisplay>> GetSnippets(string type)
Parameters
typestringThis is a string but will be 'partialViews', 'partialViewMacros'
Returns
- ActionResult<IEnumerable<SnippetDisplay>>
Returns a list of Umbraco.Cms.Core.Models.ContentEditing.SnippetDisplay if a correct type is sent
PostCreate(string, CodeFileDisplay)
Used to create a brand new file
public ActionResult<CodeFileDisplay> PostCreate(string type, CodeFileDisplay display)
Parameters
typestringThis is a string but will be 'scripts' 'partialViews', 'partialViewMacros'
displayCodeFileDisplay
Returns
- 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'
[HttpPost]
public ActionResult<CodeFileDisplay> PostCreateContainer(string type, string parentId, string name)
Parameters
typestring'partialViews', 'partialViewMacros' or 'scripts'
parentIdstringThe virtual path of the parent.
namestringThe name of the container/folder
Returns
- ActionResult<CodeFileDisplay>
PostExtractStylesheetRules(StylesheetData)
Extracts "umbraco style rules" from a style sheet
public StylesheetRule[]? PostExtractStylesheetRules(CodeFileController.StylesheetData data)
Parameters
dataCodeFileController.StylesheetDataThe style sheet data
Returns
- StylesheetRule[]
The style rules
PostInterpolateStylesheetRules(StylesheetData)
Creates a style sheet from CSS and style rules
public string? PostInterpolateStylesheetRules(CodeFileController.StylesheetData data)
Parameters
dataCodeFileController.StylesheetDataThe style sheet data
Returns
- 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 data
PostSave(CodeFileDisplay)
Used to create or update a 'partialview', 'partialviewmacro', 'script' or 'stylesheets' file
public ActionResult<CodeFileDisplay> PostSave(CodeFileDisplay display)
Parameters
displayCodeFileDisplay
Returns
- ActionResult<CodeFileDisplay>
The updated CodeFileDisplay model