Search Results for

    Show / Hide Table of Contents
    View Source

    Class ScriptService

    Provides services for managing JavaScript script files in Umbraco.

    Inheritance
    object
    RepositoryService
    FileServiceBase<IScriptRepository, IScript>
    FileServiceOperationBase<IScriptRepository, IScript, ScriptOperationStatus>
    Namespace: Umbraco.Cms.Core.Services
    Assembly: Umbraco.Core.dll
    Syntax
    public class ScriptService : FileServiceOperationBase<IScriptRepository, IScript, ScriptOperationStatus>, IService, IScriptService, IBasicFileService<IScript>
    Remarks

    This service handles CRUD operations for script files (.js) stored in the file system, including creating, updating, renaming, and deleting scripts.

    Constructors

    View Source

    ScriptService(ICoreScopeProvider, ILoggerFactory, IEventMessagesFactory, IScriptRepository, ILogger<StylesheetService>, IUserIdKeyResolver, IAuditRepository)

    Initializes a new instance of the ScriptService class.

    Declaration
    [Obsolete("Use the non-obsolete constructor instead. Scheduled for removal in Umbraco 19.")]
    public ScriptService(ICoreScopeProvider provider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, IScriptRepository repository, ILogger<StylesheetService> logger, IUserIdKeyResolver userIdKeyResolver, IAuditRepository auditRepository)
    Parameters
    Type Name Description
    ICoreScopeProvider provider

    The core scope provider for managing database transactions.

    ILoggerFactory loggerFactory

    The factory for creating loggers.

    IEventMessagesFactory eventMessagesFactory

    The factory for creating event messages.

    IScriptRepository repository

    The repository for script file operations.

    ILogger<StylesheetService> logger

    The logger instance for logging operations.

    IUserIdKeyResolver userIdKeyResolver

    The resolver for converting user keys to IDs.

    IAuditRepository auditRepository

    The repository for audit logging (obsolete).

    View Source

    ScriptService(ICoreScopeProvider, ILoggerFactory, IEventMessagesFactory, IScriptRepository, ILogger<StylesheetService>, IUserIdKeyResolver, IAuditService)

    Initializes a new instance of the ScriptService class.

    Declaration
    public ScriptService(ICoreScopeProvider provider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, IScriptRepository repository, ILogger<StylesheetService> logger, IUserIdKeyResolver userIdKeyResolver, IAuditService auditService)
    Parameters
    Type Name Description
    ICoreScopeProvider provider

    The core scope provider for managing database transactions.

    ILoggerFactory loggerFactory

    The factory for creating loggers.

    IEventMessagesFactory eventMessagesFactory

    The factory for creating event messages.

    IScriptRepository repository

    The repository for script file operations.

    ILogger<StylesheetService> logger

    The logger instance for logging operations.

    IUserIdKeyResolver userIdKeyResolver

    The resolver for converting user keys to IDs.

    IAuditService auditService

    The service for audit logging.

    View Source

    ScriptService(ICoreScopeProvider, ILoggerFactory, IEventMessagesFactory, IScriptRepository, ILogger<StylesheetService>, IUserIdKeyResolver, IAuditService, IAuditRepository)

    Initializes a new instance of the ScriptService class.

    Declaration
    [Obsolete("Use the non-obsolete constructor instead. Scheduled for removal in Umbraco 19.")]
    public ScriptService(ICoreScopeProvider provider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, IScriptRepository repository, ILogger<StylesheetService> logger, IUserIdKeyResolver userIdKeyResolver, IAuditService auditService, IAuditRepository auditRepository)
    Parameters
    Type Name Description
    ICoreScopeProvider provider

    The core scope provider for managing database transactions.

    ILoggerFactory loggerFactory

    The factory for creating loggers.

    IEventMessagesFactory eventMessagesFactory

    The factory for creating event messages.

    IScriptRepository repository

    The repository for script file operations.

    ILogger<StylesheetService> logger

    The logger instance for logging operations.

    IUserIdKeyResolver userIdKeyResolver

    The resolver for converting user keys to IDs.

    IAuditService auditService

    The service for audit logging.

    IAuditRepository auditRepository

    The repository for audit logging (obsolete).

    Properties

    View Source

    AllowedFileExtensions

    Gets the allowed file extensions for this file type.

    Declaration
    protected override string[] AllowedFileExtensions { get; }
    Property Value
    Type Description
    string[]
    View Source

    AlreadyExists

    Gets the operation status value representing an entity that already exists.

    Declaration
    protected override ScriptOperationStatus AlreadyExists { get; }
    Property Value
    Type Description
    ScriptOperationStatus
    View Source

    CancelledByNotification

    Gets the operation status value representing a cancellation by notification handler.

    Declaration
    protected override ScriptOperationStatus CancelledByNotification { get; }
    Property Value
    Type Description
    ScriptOperationStatus
    View Source

    EntityType

    Gets the entity type name used for audit logging.

    Declaration
    protected override string EntityType { get; }
    Property Value
    Type Description
    string
    View Source

    InvalidFileExtension

    Gets the operation status value representing an invalid file extension.

    Declaration
    protected override ScriptOperationStatus InvalidFileExtension { get; }
    Property Value
    Type Description
    ScriptOperationStatus
    View Source

    InvalidName

    Gets the operation status value representing an invalid file name.

    Declaration
    protected override ScriptOperationStatus InvalidName { get; }
    Property Value
    Type Description
    ScriptOperationStatus
    View Source

    NotFound

    Gets the operation status value representing an entity not found condition.

    Declaration
    protected override ScriptOperationStatus NotFound { get; }
    Property Value
    Type Description
    ScriptOperationStatus
    View Source

    ParentNotFound

    Gets the operation status value representing a parent folder not found condition.

    Declaration
    protected override ScriptOperationStatus ParentNotFound { get; }
    Property Value
    Type Description
    ScriptOperationStatus
    View Source

    PathTooLong

    Gets the operation status value representing a path that exceeds maximum length.

    Declaration
    protected override ScriptOperationStatus PathTooLong { get; }
    Property Value
    Type Description
    ScriptOperationStatus
    View Source

    Success

    Gets the operation status value representing a successful operation.

    Declaration
    protected override ScriptOperationStatus Success { get; }
    Property Value
    Type Description
    ScriptOperationStatus

    Methods

    View Source

    CreateAsync(ScriptCreateModel, Guid)

    Creates a new script.

    Declaration
    public Task<Attempt<IScript?, ScriptOperationStatus>> CreateAsync(ScriptCreateModel createModel, Guid userKey)
    Parameters
    Type Name Description
    ScriptCreateModel createModel

    ScriptCreateModel containing the information about the script being created.

    Guid userKey

    The key of the user performing the operation.

    Returns
    Type Description
    Task<Attempt<IScript, ScriptOperationStatus>>

    An attempt indicating if the operation was a success as well as a more detailed ScriptOperationStatus.

    View Source

    CreateEntity(string, string?)

    Creates a new entity instance with the specified path and content.

    Declaration
    protected override IScript CreateEntity(string path, string? content)
    Parameters
    Type Name Description
    string path

    The file path for the entity.

    string content

    The optional content of the file.

    Returns
    Type Description
    IScript

    A new entity instance.

    View Source

    DeleteAsync(string, Guid)

    Deletes a Script.

    Declaration
    public Task<ScriptOperationStatus> DeleteAsync(string path, Guid userKey)
    Parameters
    Type Name Description
    string path

    The path of the script to delete.

    Guid userKey

    The key of the user performing the operation.

    Returns
    Type Description
    Task<ScriptOperationStatus>

    An operation status.

    View Source

    DeletedNotification(IScript, EventMessages)

    Creates a deleted notification for the specified entity.

    Declaration
    protected override ScriptDeletedNotification DeletedNotification(IScript target, EventMessages messages)
    Parameters
    Type Name Description
    IScript target

    The entity that was deleted.

    EventMessages messages

    The event messages to include.

    Returns
    Type Description
    ScriptDeletedNotification

    A deleted notification instance.

    View Source

    DeletingNotification(IScript, EventMessages)

    Creates a deleting notification for the specified entity.

    Declaration
    protected override ScriptDeletingNotification DeletingNotification(IScript target, EventMessages messages)
    Parameters
    Type Name Description
    IScript target

    The entity being deleted.

    EventMessages messages

    The event messages to include.

    Returns
    Type Description
    ScriptDeletingNotification

    A deleting notification instance.

    View Source

    RenameAsync(string, ScriptRenameModel, Guid)

    Renames a script.

    Declaration
    public Task<Attempt<IScript?, ScriptOperationStatus>> RenameAsync(string path, ScriptRenameModel renameModel, Guid userKey)
    Parameters
    Type Name Description
    string path

    The path of the script to rename.

    ScriptRenameModel renameModel

    A ScriptRenameModel with the changes.

    Guid userKey

    The key of the user performing the operation.

    Returns
    Type Description
    Task<Attempt<IScript, ScriptOperationStatus>>

    An attempt indicating if the operation was a success as well as a more detailed ScriptOperationStatus.

    View Source

    SavedNotification(IScript, EventMessages)

    Creates a saved notification for the specified entity.

    Declaration
    protected override ScriptSavedNotification SavedNotification(IScript target, EventMessages messages)
    Parameters
    Type Name Description
    IScript target

    The entity that was saved.

    EventMessages messages

    The event messages to include.

    Returns
    Type Description
    ScriptSavedNotification

    A saved notification instance.

    View Source

    SavingNotification(IScript, EventMessages)

    Creates a saving notification for the specified entity.

    Declaration
    protected override ScriptSavingNotification SavingNotification(IScript target, EventMessages messages)
    Parameters
    Type Name Description
    IScript target

    The entity being saved.

    EventMessages messages

    The event messages to include.

    Returns
    Type Description
    ScriptSavingNotification

    A saving notification instance.

    View Source

    UpdateAsync(string, ScriptUpdateModel, Guid)

    Updates an existing script.

    Declaration
    public Task<Attempt<IScript?, ScriptOperationStatus>> UpdateAsync(string path, ScriptUpdateModel updateModel, Guid userKey)
    Parameters
    Type Name Description
    string path

    The path of the script to update.

    ScriptUpdateModel updateModel

    A ScriptUpdateModel with the changes.

    Guid userKey

    The key of the user performing the operation.

    Returns
    Type Description
    Task<Attempt<IScript, ScriptOperationStatus>>

    An attempt indicating if the operation was a success as well as a more detailed ScriptOperationStatus.

    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX