Search Results for

    Show / Hide Table of Contents
    View Source

    Class CodeFileController

    Inheritance
    System.Object
    Microsoft.AspNetCore.Mvc.ControllerBase
    UmbracoApiControllerBase
    UmbracoApiController
    UmbracoAuthorizedApiController
    UmbracoAuthorizedJsonController
    BackOfficeNotificationsController
    Namespace: Umbraco.Cms.Web.BackOffice.Controllers
    Assembly: Umbraco.Web.BackOffice.dll
    Syntax
    [Authorize(Policy = "SectionAccessSettings")]
    public class CodeFileController : BackOfficeNotificationsController

    Constructors

    View Source

    CodeFileController(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
    View Source

    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 Source

    Delete(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

    View Source

    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<System.Nullable<CodeFileDisplay>>

    The file and its contents from the virtualPath

    View Source

    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<System.Nullable<CodeFileDisplay>>
    View Source

    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 if a correct type is sent

    View Source

    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

    View Source

    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>
    View Source

    PostExtractStylesheetRules(CodeFileController.StylesheetData)

    Extracts "umbraco style rules" from a style sheet

    Declaration
    public Models.ContentEditing.StylesheetRule[] PostExtractStylesheetRules(CodeFileController.StylesheetData data)
    Parameters
    Type Name Description
    CodeFileController.StylesheetData data

    The style sheet data

    Returns
    Type Description
    Models.ContentEditing.StylesheetRule[]

    The style rules

    View Source

    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 data

    View Source

    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

    • Improve this Doc
    • View Source
    In This Article
    • Constructors
      • CodeFileController(IHostingEnvironment, FileSystems, IFileService, IBackOfficeSecurityAccessor, ILocalizedTextService, IUmbracoMapper, IShortStringHelper, IOptionsSnapshot<GlobalSettings>)
      • CodeFileController(IHostingEnvironment, FileSystems, IFileService, IBackOfficeSecurityAccessor, ILocalizedTextService, IUmbracoMapper, IShortStringHelper, IOptionsSnapshot<GlobalSettings>, PartialViewSnippetCollection, PartialViewMacroSnippetCollection)
    • Methods
      • Delete(String, String)
      • GetByPath(String, String)
      • GetScaffold(String, String, String)
      • GetSnippets(String)
      • PostCreate(String, CodeFileDisplay)
      • PostCreateContainer(String, String, String)
      • PostExtractStylesheetRules(CodeFileController.StylesheetData)
      • PostInterpolateStylesheetRules(CodeFileController.StylesheetData)
      • PostSave(CodeFileDisplay)
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX