contentbox.models.system

Class SettingService

lucee.Component
    extended by cborm.models.BaseORMService
      extended by cborm.models.VirtualEntityService
        extended by contentbox.models.system.SettingService

ContentBox - A Modular Content Platform Copyright since 2012 by Ortus Solutions, Corp www.ortussolutions.com/products/contentbox --- Setting Service for ContentBox apps. All settings are cached as a struct constructed using the following format: - global : { name : value } // global settings - sites : { slug : { name : value } }

Class Attributes:
  • threadsafe
  •  
  • singleton
  •  
  • synchronized : false
  •  
  • accessors : true
  •  
  • persistent : false
  •  
    Property Summary
    type property default serializable required
    boolean CBReadyFlag
          Bit that detects if CB has been installed or not.

    • access = public
    • returntype = any
    false true false
    any appName


    • access = public
    • returntype = any
    • inject = coldbox:setting:appName
    true false
    any cacheProviderName
          The cache provider name to use for settings caching.

    • access = public
    • returntype = any
    template true false
    any cachebox


    • access = public
    • returntype = any
    • inject = cachebox
    true false
    any contentboxSettings


    • access = public
    • returntype = any
    • inject = coldbox:moduleSettings:contentbox
    true false
    any log


    • access = public
    • returntype = any
    • inject = logbox:logger:{this}
    true false
    any moduleSettings


    • access = public
    • returntype = any
    • inject = coldbox:setting:modules
    true false
    any siteService


    • access = public
    • returntype = any
    • inject = siteService@contentbox
    true false
    Constructor Summary
    init()
          Constructor.
    Method Summary
    SettingService activateCB()
         Mark cb as ready to serve.
    struct buildFileBrowserSettings()
         Build file browser settings structure so you can execute multiple containers.
    struct buildSettingsContainer()
         Build out a settings container by global and sites.
    SettingService bulkSave([struct memento], [any site])
         Bulk saving of options using a memento structure of options.
    boolean deleteInstaller()
         Delete the installer module.
    any findSiteSetting(any site, any name)
         Try to find a setting object by site and name.
    SettingService flushSettingsCache()
         flush settings cache for current multi-tenant host.
    array getAllForExport()
         Get all data prepared for export.
    struct getAllSettings([boolean force='false'])
         Get all global settings.
    struct getAllSiteSettings(any siteSlug, [boolean force='false'])
         Get all site settings.
    string getAppName()
    string getCBReadyFlag()
    string getCacheProviderName()
    string getCachebox()
    string getContentboxSettings()
    struct getDefaultSiteSettings([boolean force='false'])
         Get all the default site settings.
    string getLog()
    string getModuleSettings()
    any getSetting(any name, [any defaultValue])
         Get a global setting.
    string getSettingsCacheKey()
         The static key used for caching all the settings of this installation.
    any getSettingsCacheProvider()
         Get the cache provider object to be used for settings.
    struct getSettingsContainer([boolean force='false'])
         Get the entire settings container from cache or build it out.
    string getSiteService()
    any getSiteSetting(any siteSlug, any name, [any defaultValue])
         Get a site setting.
    struct getSiteSettingDefaults()
         Get a collection (struct) of settings that represent the defaults for a site in ContentBox.
    string importFromData(any importData, [boolean override='false'], [any importLog])
         Import data from an array of structures or a single structure of data.
    string importFromFile(any importFile, [boolean override='false'])
         Import data from a ContentBox JSON file.
    boolean isCBReady()
         Check if contentbox has been installed by checking if there are no settings and no cb_active ONLY.
    boolean isInstallationPresent()
         Check if the installer is present.
    private SettingService loadCacheProviderName()
         Load the cache provider name from DB or default value.
    any loadConfigOverrides()
         Load up config overrides.
    any loadEnvironmentOverrides()
         Load up java environment overrides for ContentBox settings.
    SettingService preFlightCheck()
         This method will go over all system settings and make sure that there are no missing default core settings.
    struct search([any search=''], [any max='0'], [any offset='0'], [any sortOrder='name asc'], [any siteID=''])
         Setting search with filters.
    any setAppName(any appName)
    any setCBReadyFlag(boolean CBReadyFlag)
    any setCacheProviderName(any cacheProviderName)
    any setCachebox(any cachebox)
    any setContentboxSettings(any contentboxSettings)
    any setLog(any log)
    any setModuleSettings(any moduleSettings)
    any setSiteService(any siteService)
    SettingService storeSettings([struct settings])
         This will store the incoming structure as the settings in cache.
     
    Methods inherited from class cborm.models.VirtualEntityService
    autoCast, convertIdValueToJavaType, convertValueToJavaType, count, countWhere, deleteAll, deleteByID, deleteByQuery, deleteWhere, evictCollection, executeQuery, exists, findAllWhere, findWhere, get, getAll, getEntityName, getKey, getOrFail, getPropertyNames, getTableName, idCast, list, new, newCriteria, onMissingMethod, setEntityName
     
    Methods inherited from class cborm.models.BaseORMService
    $transactioned, buildJavaProxy, clear, createService, delete, evict, evictQueries, findAll, findByExample, findIt, findOrFail, getBeanPopulator, getDatasource, getDefaultAsQuery, getDirtyPropertyNames, getDynamicProcessor, getEntityGivenName, getEntityMetadata, getEventHandling, getKeyValue, getLogger, getORMEventHandler, getObjectPopulator, getOrm, getPropertyValues, getQueryCacheRegion, getRestrictions, getSessionStatistics, getStringBuilder, getUseQueryCaching, getUseTransactions, getWirebox, isDirty, isSessionDirty, merge, nullValue, populate, populateFromJson, populateFromQuery, populateFromXml, populateWithPrefix, refresh, save, saveAll, sessionContains, setDatasource, setDefaultAsQuery, setEventHandling, setLogger, setORM, setORMEventHandler, setQueryCacheRegion, setUseQueryCaching, setUseTransactions, setWirebox, when
     
    Methods inherited from class lucee.Component
    None

    Constructor Detail

    init

    public init()

    Constructor


    Property Detail

    CBReadyFlag

    property boolean CBReadyFlag = [false]

    Bit that detects if CB has been installed or not

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    appName

    property any appName

    Attributes:
    access - public
    required - false
    returntype - any
    inject - coldbox:setting:appName
    serializable - true

    cacheProviderName

    property any cacheProviderName = [template]

    The cache provider name to use for settings caching. Defaults to 'template' cache. This can also be set in the global ContentBox settings page to any CacheBox cache.

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    cachebox

    property any cachebox

    Attributes:
    access - public
    required - false
    returntype - any
    inject - cachebox
    serializable - true

    contentboxSettings

    property any contentboxSettings

    Attributes:
    access - public
    required - false
    returntype - any
    inject - coldbox:moduleSettings:contentbox
    serializable - true

    log

    property any log

    Attributes:
    access - public
    required - false
    returntype - any
    inject - logbox:logger:{this}
    serializable - true

    moduleSettings

    property any moduleSettings

    Attributes:
    access - public
    required - false
    returntype - any
    inject - coldbox:setting:modules
    serializable - true

    siteService

    property any siteService

    Attributes:
    access - public
    required - false
    returntype - any
    inject - siteService@contentbox
    serializable - true

    Method Detail

    activateCB

    public SettingService activateCB()

    Mark cb as ready to serve


    buildFileBrowserSettings

    public struct buildFileBrowserSettings()

    Build file browser settings structure so you can execute multiple containers

    Returns:
    struct

    buildSettingsContainer

    public struct buildSettingsContainer()

    Build out a settings container by global and sites.

    Returns:
    struct of { global : {}, sites : { slug : {} } }

    bulkSave

    public SettingService bulkSave([struct memento], [any site])

    Bulk saving of options using a memento structure of options This is usually done from the settings display manager

    Parameters:
    memento - The struct of settings
    site - Optional site to attach the settings to
    Returns:
    SettingService

    deleteInstaller

    public boolean deleteInstaller()

    Delete the installer module


    findSiteSetting

    public any findSiteSetting(any site, any name)

    Try to find a setting object by site and name

    Parameters:
    site
    name
    Returns:
    The setting object or null

    flushSettingsCache

    public SettingService flushSettingsCache()

    flush settings cache for current multi-tenant host


    getAllForExport

    public array getAllForExport()

    Get all data prepared for export


    getAllSettings

    public struct getAllSettings([boolean force='false'])

    Get all global settings

    Parameters:
    force - To force clear the cache

    getAllSiteSettings

    public struct getAllSiteSettings(any siteSlug, [boolean force='false'])

    Get all site settings

    Parameters:
    siteSlug
    force - To force clear the cache

    getAppName

    public string getAppName()


    getCBReadyFlag

    public string getCBReadyFlag()


    getCacheProviderName

    public string getCacheProviderName()


    getCachebox

    public string getCachebox()


    getContentboxSettings

    public string getContentboxSettings()


    getDefaultSiteSettings

    public struct getDefaultSiteSettings([boolean force='false'])

    Get all the default site settings

    Parameters:
    force - To force clear the cache

    getLog

    public string getLog()


    getModuleSettings

    public string getModuleSettings()


    getSetting

    public any getSetting(any name, [any defaultValue])

    Get a global setting

    Parameters:
    name - The name of the seting
    defaultValue - The default value if setting not found.
    Returns:
    The setting value or default value if not found
    Throws:
    SettingNotFoundException

    getSettingsCacheKey

    public string getSettingsCacheKey()

    The static key used for caching all the settings of this installation


    getSettingsCacheProvider

    public any getSettingsCacheProvider()

    Get the cache provider object to be used for settings

    Returns:
    coldbox.system.cache.ICacheProvider

    getSettingsContainer

    public struct getSettingsContainer([boolean force='false'])

    Get the entire settings container from cache or build it out.

    Parameters:
    force - Force build

    getSiteService

    public string getSiteService()


    getSiteSetting

    public any getSiteSetting(any siteSlug, any name, [any defaultValue])

    Get a site setting

    Parameters:
    siteSlug - The site to get the setting from
    name - The name of the seting
    defaultValue - The default value if setting not found.
    Returns:
    The setting value or default value if not found
    Throws:
    SettingNotFoundException

    getSiteSettingDefaults

    public struct getSiteSettingDefaults()

    Get a collection (struct) of settings that represent the defaults for a site in ContentBox


    importFromData

    public string importFromData(any importData, [boolean override='false'], [any importLog])

    Import data from an array of structures or a single structure of data

    Parameters:
    importData - A struct or array of data to import
    override - Override content if found in the database, defaults to false
    importLog - The import log buffer
    Returns:
    The console log of the import
    Throws:
    InvalidImportFormat

    importFromFile

    public string importFromFile(any importFile, [boolean override='false'])

    Import data from a ContentBox JSON file. Returns the import log

    Parameters:
    importFile - The json file to import
    override - Override content if found in the database, defaults to false
    Returns:
    The console log of the import
    Throws:
    InvalidImportFormat

    isCBReady

    public boolean isCBReady()

    Check if contentbox has been installed by checking if there are no settings and no cb_active ONLY If the query comes back with active, it will not run it again.


    isInstallationPresent

    public boolean isInstallationPresent()

    Check if the installer is present


    loadCacheProviderName

    private SettingService loadCacheProviderName()

    Load the cache provider name from DB or default value


    loadConfigOverrides

    public any loadConfigOverrides()

    Load up config overrides


    loadEnvironmentOverrides

    public any loadEnvironmentOverrides()

    Load up java environment overrides for ContentBox settings The pattern to look is `contentbox.{site}.{setting}` Example: contentbox.default.cb_media_directoryRoot


    preFlightCheck

    public SettingService preFlightCheck()

    This method will go over all system settings and make sure that there are no missing default core settings. If they are, we will create the core settings with the appropriate defaults: this.DEFAULTS


    search

    public struct search([any search=''], [any max='0'], [any offset='0'], [any sortOrder='name asc'], [any siteID=''])

    Setting search with filters

    Parameters:
    search - The search term for the name
    max - The max records
    offset - The offset to tuse
    sortOrder - The sort order
    siteID - The site id to filter on
    Returns:
    struct of { count, settings }

    setAppName

    public any setAppName(any appName)

    Parameters:
    appName

    setCBReadyFlag

    public any setCBReadyFlag(boolean CBReadyFlag)

    Parameters:
    CBReadyFlag

    setCacheProviderName

    public any setCacheProviderName(any cacheProviderName)

    Parameters:
    cacheProviderName

    setCachebox

    public any setCachebox(any cachebox)

    Parameters:
    cachebox

    setContentboxSettings

    public any setContentboxSettings(any contentboxSettings)

    Parameters:
    contentboxSettings

    setLog

    public any setLog(any log)

    Parameters:
    log

    setModuleSettings

    public any setModuleSettings(any moduleSettings)

    Parameters:
    moduleSettings

    setSiteService

    public any setSiteService(any siteService)

    Parameters:
    siteService

    storeSettings

    public SettingService storeSettings([struct settings])

    This will store the incoming structure as the settings in cache. Usually this method is used for major overrides.

    Parameters:
    settings