Tags ​
- Type
- Class
- Namespace
- craft\services
- Inherits
- craft\services\Tags » yii\base\Component » yii\base\BaseObject
- Implements
- yii\base\Configurable
- Since
- 3.0.0
Tags service.
An instance of the service is available via Craft::$app->getTags().
Public Properties ​
| Property | Description |
|---|---|
| allTagGroupIds | array |
| allTagGroups | craft\models\TagGroup[] |
| behaviors | yii\base\Behavior – List of behaviors attached to this component. |
| totalTagGroups | integer |
allTagGroupIds ​
- Type
- array
- Default value
null- Access
- Read-only
allTagGroups ​
- Type
- craft\models\TagGroup[]
- Default value
null- Access
- Read-only
totalTagGroups ​
- Type
- integer
- Default value
null- Access
- Read-only
Public Methods ​
| Method | Description |
|---|---|
| __call() | Calls the named method which is not a class method. |
| __clone() | This method is called after the object is created by cloning an existing one. |
| __construct() | Constructor. |
| __get() | Returns the value of a component property. |
| __isset() | Checks if a property is set, i.e. defined and not null. |
| __serialize() | Serializer |
| __set() | Sets the value of a component property. |
| __unset() | Sets a component property to be null. |
| attachBehavior() | Attaches a behavior to this component. |
| attachBehaviors() | Attaches a list of behaviors to the component. |
| behaviors() | Returns a list of behaviors that this component should behave as. |
| canGetProperty() | Returns a value indicating whether a property can be read. |
| canSetProperty() | Returns a value indicating whether a property can be set. |
| className() | Returns the fully qualified name of this class. |
| deleteTagGroup() | Deletes a tag group. |
| deleteTagGroupById() | Deletes a tag group by its ID. |
| detachBehavior() | Detaches a behavior from the component. |
| detachBehaviors() | Detaches all behaviors from the component. |
| ensureBehaviors() | Makes sure that the behaviors declared in behaviors() are attached to this component. |
| getAllTagGroupIds() | Returns all of the group IDs. |
| getAllTagGroups() | Returns all tag groups. |
| getBehavior() | Returns the named behavior object. |
| getBehaviors() | Returns all behaviors attached to this component. |
| getTagById() | Returns a tag by its ID. |
| getTagGroupByHandle() | Gets a group by its handle. |
| getTagGroupById() | Returns a group by its ID. |
| getTagGroupByUid() | Returns a group by its UID. |
| getTotalTagGroups() | Gets the total number of tag groups. |
| handleChangedTagGroup() | Handle tag group change |
| handleDeletedTagGroup() | Handle Tag group getting deleted |
| hasEventHandlers() | Returns a value indicating whether there is any handler attached to the named event. |
| hasMethod() | Returns a value indicating whether a method is defined. |
| hasProperty() | Returns a value indicating whether a property is defined for this component. |
| init() | Initializes the object. |
| off() | Detaches an existing event handler from this component. |
| on() | Attaches an event handler to an event. |
| pruneDeletedField() | |
| saveTagGroup() | Saves a tag group. |
| trigger() | Triggers an event. |
__serialize() ​
- Since
- 3.5.14
Serializer
deleteTagGroup() ​
Deletes a tag group.
Arguments ​
$tagGroup(craft\models\TagGroup) – The tag group
Returns ​
boolean – Whether the tag group was deleted successfully
Throws ​
- Throwable
if reasons
deleteTagGroupById() ​
- Since
- 3.0.12
Deletes a tag group by its ID.
Arguments ​
$groupId(integer) – The tag group's ID
Returns ​
boolean – Whether the tag group was deleted successfully
Throws ​
- Throwable
if reasons
getAllTagGroupIds() ​
Returns all of the group IDs.
Returns ​
getAllTagGroups() ​
Returns all tag groups.
Returns ​
getTagById() ​
Returns a tag by its ID.
Arguments ​
Returns ​
getTagGroupByHandle() ​
Gets a group by its handle.
Arguments ​
Returns ​
getTagGroupById() ​
Returns a group by its ID.
Arguments ​
$groupId(integer)
Returns ​
getTagGroupByUid() ​
Returns a group by its UID.
Arguments ​
$groupUid(string)
Returns ​
getTotalTagGroups() ​
Gets the total number of tag groups.
Returns ​
handleChangedTagGroup() ​
Handle tag group change
Arguments ​
$event(craft\events\ConfigEvent)
handleDeletedTagGroup() ​
Handle Tag group getting deleted
Arguments ​
$event(craft\events\ConfigEvent)
pruneDeletedField() ​
DEPRECATED
Deprecated in 4.0.5. Unused fields will be pruned automatically as field layouts are resaved.
saveTagGroup() ​
Saves a tag group.
Arguments ​
$tagGroup(craft\models\TagGroup) – The tag group to be saved$runValidation(boolean) – Whether the tag group should be validated
Returns ​
boolean – Whether the tag group was saved successfully
Throws ​
- craft\errors\TagGroupNotFoundException
if $tagGroup->id is invalid - Throwable
if reasons
Events ​
EVENT_AFTER_DELETE_GROUP ​
The event that is triggered after a tag group is deleted.
EVENT_AFTER_SAVE_GROUP ​
The event that is triggered after a tag group is saved.
EVENT_BEFORE_APPLY_GROUP_DELETE ​
- Type
- craft\events\TagGroupEvent
- Since
- 3.1.0
The event that is triggered before a tag group delete is applied to the database.
EVENT_BEFORE_DELETE_GROUP ​
The event that is triggered before a tag group is deleted.
EVENT_BEFORE_SAVE_GROUP ​
The event that is triggered before a tag group is saved.