contentbox.models.content

Class CategoryService

lucee.Component
    extended by cborm.models.BaseORMService
      extended by cborm.models.VirtualEntityService
        extended by contentbox.models.content.CategoryService

ContentBox - A Modular Content Platform Copyright since 2012 by Ortus Solutions, Corp www.ortussolutions.com/products/contentbox --- Category service for contentbox

Class Attributes:
  • singleton
  •  
  • synchronized : false
  •  
  • accessors : false
  •  
  • persistent : false
  •  
    Property Summary
    type property default serializable required
    any contentService


    • access = public
    • returntype = any
    • inject = contentService@contentbox
    true false
    any dateUtil


    • access = public
    • returntype = any
    • inject = DateUtil@contentbox
    true false
    any htmlHelper


    • access = public
    • returntype = any
    • inject = HTMLHelper@coldbox
    true false
    Constructor Summary
    init()
          Constructor.
    Method Summary
    array createCategories(any categories, any site, [boolean isPublic='true'])
         Create categories via a comma delimited list and return the entities created.
    boolean delete(any category)
         Delete a category which also removes itself from all many-to-many relationships.
    array getAllForExport(any site)
         Get all data prepared for export.
    array getAllNames([string siteID=''], [boolean isPublic])
         Get an array of names of all categories in the system or by site.
    array getAllSlugs([string siteID=''], [boolean isPublic])
         Get an array of slugs of all categories in the system.
    Category getOrCreate(any category, any site)
         This function allows you to receive a category object from a site and.
    Category getOrCreateBySlug(string category, any site)
         This function allows you to receive a category slug string from a site and.
    numeric getTotalCategoryCount([string siteID=''])
         Get the total category counts for the entire installation or by site.
    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.
    array inflateCategories([struct memento])
         Inflate categories from a collection via 'category_X' pattern and returns an array of category objects.
    boolean isSlugUnique(any slug, [any categoryID=''], [string siteID=''])
         Verify an incoming slug is unique or not.
    array removeAllRelatedContent(any category)
    any save(any category)
         Save a category in the system.
    struct search([any search=''], [any siteID=''], [boolean isPublic], [any max='0'], [any offset='0'], [any sortOrder='category asc'])
         Category search with filters.
     
    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, 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, 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

    contentService

    property any contentService

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

    dateUtil

    property any dateUtil

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

    htmlHelper

    property any htmlHelper

    Attributes:
    access - public
    required - false
    returntype - any
    inject - HTMLHelper@coldbox
    serializable - true

    Method Detail

    createCategories

    public array createCategories(any categories, any site, [boolean isPublic='true'])

    Create categories via a comma delimited list and return the entities created

    Parameters:
    categories - A list or array of categories to create
    site - The site to attach them to, this must be a site object
    isPublic - Create public or private categories

    delete

    public boolean delete(any category)

    Delete a category which also removes itself from all many-to-many relationships

    Overrides:
    delete in class cborm.models.BaseORMService
    Parameters:
    category - The category object to remove from the system

    getAllForExport

    public array getAllForExport(any site)

    Get all data prepared for export

    Parameters:
    site - The site to export from

    getAllNames

    public array getAllNames([string siteID=''], [boolean isPublic])

    Get an array of names of all categories in the system or by site

    Parameters:
    siteID - The site to filter the names from
    isPublic - If passed, show by this filter, else all categories

    getAllSlugs

    public array getAllSlugs([string siteID=''], [boolean isPublic])

    Get an array of slugs of all categories in the system

    Parameters:
    siteID - The site to filter the names from
    isPublic - If passed, show by this filter, else all categories

    getOrCreate

    public Category getOrCreate(any category, any site)

    This function allows you to receive a category object from a site and tries to see if it exists in a new site via slug comparison. If it exists, it returns it, else it creates it and returns it.

    Parameters:
    category - The target category object to check
    site - The target site this category should be created in
    Returns:
    The target site category

    getOrCreateBySlug

    public Category getOrCreateBySlug(string category, any site)

    This function allows you to receive a category slug string from a site and tries to see if it exists in a new site via slug comparison. If it exists, it returns it, else it creates it and returns it.

    Parameters:
    category - The target category slug to check
    site - The target site this category should be created in
    Returns:
    The target site category object

    getTotalCategoryCount

    public numeric getTotalCategoryCount([string siteID=''])

    Get the total category counts for the entire installation or by site

    Parameters:
    siteID - The site to filter on

    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

    inflateCategories

    public array inflateCategories([struct memento])

    Inflate categories from a collection via 'category_X' pattern and returns an array of category objects as its representation. This is done by the content editors to display the categories for selection.

    Parameters:
    memento
    Returns:
    array of categories

    isSlugUnique

    public boolean isSlugUnique(any slug, [any categoryID=''], [string siteID=''])

    Verify an incoming slug is unique or not

    Parameters:
    slug - The slug to search for uniqueness
    categoryID - Limit the search to the passed categoryId usually for updates
    siteID - The site to filter on
    Returns:
    True if the slug is unique or false if it's already used

    removeAllRelatedContent

    public array removeAllRelatedContent(any category)

    Parameters:
    category

    save

    public any save(any category)

    Save a category in the system

    Overrides:
    save in class cborm.models.BaseORMService
    Parameters:
    category - The category object
    Returns:
    The saved category
    Throws:
    UniqueCategoryException

    search

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

    Category search with filters

    Parameters:
    search - The search term for the name
    siteID - The site id to filter on
    isPublic - Filter on this public (true) / private (false) or all (null)
    max - The max records
    offset - The offset to use
    sortOrder - The sort order
    Returns:
    struct of { count, categories }