CategoriesService

Type
Class
Namespace
Craft
Inherits
Craft\CategoriesService » Craft\BaseApplicationComponent » CApplicationComponent » CComponent
Implements
IApplicationComponent
Since
2.0

Class CategoriesService

See also http://craftcms.com

View source

Public Properties

PropertyDescription
$behaviorsarray – The behaviors that should be attached to this component.

Public Methods

MethodDescription
__call()Calls the named method which is not a class method.
__get()Returns a property value, an event handler list or a behavior based on its name.
__isset()Checks if a property value is null.
__set()Sets value of a component property.
__unset()Sets a component property to be null.
asa()Returns the named behavior object.
attachBehavior()Attaches a behavior to this component.
attachBehaviors()Attaches a list of behaviors to the component.
attachEventHandler()Attaches an event handler to an event.
canGetProperty()Determines whether a property can be read.
canSetProperty()Determines whether a property can be set.
deleteCategory()Deletes a category(s).
deleteCategoryById()Deletes an category(s) by its ID.
deleteGroupById()Deletes a category group by its ID.
detachBehavior()Detaches a behavior from the component.
detachBehaviors()Detaches all behaviors from the component.
detachEventHandler()Detaches an existing event handler.
disableBehavior()Disables an attached behavior.
disableBehaviors()Disables all behaviors attached to this component.
enableBehavior()Enables an attached behavior.
enableBehaviors()Enables all behaviors attached to this component.
evaluateExpression()Evaluates a PHP expression or callback under the context of this component.
fillGapsInCategoryIds()Updates a list of category IDs, filling in any gaps in the family tree.
getAllGroupIds()Returns all of the group IDs.
getAllGroups()Returns all category groups.
getCategoryById()Returns a category by its ID.
getEditableGroupIds()Returns all of the category group IDs that are editable by the current user.
getEditableGroups()Returns all editable groups.
getEventHandlers()Returns the list of attached event handlers for an event.
getGroupByHandle()Returns a group by its handle.
getGroupById()Returns a group by its ID.
getGroupLocales()Returns a group's locales.
getIsInitialized()Checks if this application component has been initialized.
getTotalGroups()Gets the total number of category groups.
hasEvent()Determines whether an event is defined.
hasEventHandler()Checks whether the named event has attached handlers.
hasProperty()Determines whether a property is defined.
init()Initializes the application component.
isGroupTemplateValid()Returns whether a group’s categories have URLs, and if the group’s template path is valid.
isInitialized()Checks if this application component has been initialized yet, or not.
onBeforeDeleteCategory()Fires an 'onBeforeDeleteCategory' event.
onBeforeDeleteGroup()Fires an 'onBeforeDeleteGroup' event.
onBeforeSaveCategory()Fires an 'onBeforeSaveCategory' event.
onDeleteCategory()Fires an 'onDeleteCategory' event.
onDeleteGroup()Fires an 'onDeleteGroup' event.
onSaveCategory()Fires an 'onSaveCategory' event.
raiseEvent()Raises an event.
saveCategory()Saves a category.
saveGroup()Saves a category group.

deleteCategory()

Deletes a category(s).

View source

Arguments

Returns

boolean

Throws

Signature

public boolean deleteCategory ( $categories )

deleteCategoryById()

Deletes an category(s) by its ID.

View source

Arguments

Returns

boolean

Signature

public boolean deleteCategoryById ( $categoryId )

deleteGroupById()

Deletes a category group by its ID.

View source

Arguments

Returns

boolean

Throws

Signature

public boolean deleteGroupById ( $groupId )

fillGapsInCategoryIds()

Updates a list of category IDs, filling in any gaps in the family tree.

View source

Arguments

  • $ids (array) – The original list of category IDs

Returns

array – The list of category IDs with all the gaps filled in.

Signature

public array fillGapsInCategoryIds ( $ids )

getAllGroupIds()

Returns all of the group IDs.

View source

Returns

array

Signature

public array getAllGroupIds ( )

getAllGroups()

Returns all category groups.

View source

Arguments

Returns

array

Signature

public array getAllGroups ( $indexBy = null )

getCategoryById()

Returns a category by its ID.

View source

Arguments

Returns

Craft\CategoryModel, null

Signature

public Craft\CategoryModel, null getCategoryById ( $categoryId, $localeId = null )

getEditableGroupIds()

Returns all of the category group IDs that are editable by the current user.

View source

Returns

array

Signature

public array getEditableGroupIds ( )

getEditableGroups()

Returns all editable groups.

View source

Arguments

Returns

array

Signature

public array getEditableGroups ( $indexBy = null )

getGroupByHandle()

Returns a group by its handle.

View source

Arguments

Returns

Craft\CategoryGroupModel, null

Signature

public Craft\CategoryGroupModel, null getGroupByHandle ( $groupHandle )

getGroupById()

Returns a group by its ID.

View source

Arguments

Returns

Craft\CategoryGroupModel, null

Signature

public Craft\CategoryGroupModel, null getGroupById ( $groupId )

getGroupLocales()

Returns a group's locales.

View source

Arguments

Returns

array

Signature

public array getGroupLocales ( $groupId, $indexBy = null )

getTotalGroups()

Gets the total number of category groups.

View source

Returns

integer

Signature

public integer getTotalGroups ( )

isGroupTemplateValid()

Returns whether a group’s categories have URLs, and if the group’s template path is valid.

View source

Arguments

Returns

boolean

Signature

public boolean isGroupTemplateValid ( Craft\CategoryGroupModel $group )

onBeforeDeleteCategory()

Fires an 'onBeforeDeleteCategory' event.

View source

Arguments

Returns

null

Signature

public null onBeforeDeleteCategory ( Craft\Event $event )

onBeforeDeleteGroup()

Fires an 'onBeforeDeleteGroup' event.

View source

Arguments

Returns

null

Signature

public null onBeforeDeleteGroup ( Craft\Event $event )

onBeforeSaveCategory()

Fires an 'onBeforeSaveCategory' event.

View source

Arguments

Returns

null

Signature

public null onBeforeSaveCategory ( Craft\Event $event )

onDeleteCategory()

Fires an 'onDeleteCategory' event.

View source

Arguments

Returns

null

Signature

public null onDeleteCategory ( Craft\Event $event )

onDeleteGroup()

Fires an 'onDeleteGroup' event.

View source

Arguments

Returns

null

Signature

public null onDeleteGroup ( Craft\Event $event )

onSaveCategory()

Fires an 'onSaveCategory' event.

View source

Arguments

Returns

null

Signature

public null onSaveCategory ( Craft\Event $event )

saveCategory()

Saves a category.

View source

Arguments

Returns

boolean

Throws

  • \Craft\Exception|\Exception

Signature

public boolean saveCategory ( Craft\CategoryModel $category )

saveGroup()

Saves a category group.

View source

Arguments

Returns

boolean

Throws

Signature

public boolean saveGroup ( Craft\CategoryGroupModel $group )