Class craft\services\Tags
- Inheritance
- craft\services\Tags » yii\base\Component » yii\base\BaseObject
- Implements
- yii\base\Configurable
- Available since version
- 3.0
- Source Code
- https://github.com/craftcms/cms/blob/master/src/services/Tags.php
Tags service.
An instance of the Tags service is globally accessible in Craft via Craft::$app->tags
.
Method | Description | Defined By |
---|---|---|
__call() |
Calls the named method which is not a class method. | yii\base\BaseObject |
__clone() |
This method is called after the object is created by cloning an existing one. | yii\base\Component |
__construct() |
Constructor. | yii\base\BaseObject |
__get() |
Returns the value of an object property. | yii\base\BaseObject |
__isset() |
Checks if a property is set, i.e. defined and not null. | yii\base\BaseObject |
__set() |
Sets value of an object property. | yii\base\BaseObject |
__unset() |
Sets an object property to null. | yii\base\BaseObject |
attachBehavior() |
Attaches a behavior to this component. | yii\base\Component |
attachBehaviors() |
Attaches a list of behaviors to the component. | yii\base\Component |
behaviors() |
Returns a list of behaviors that this component should behave as. | yii\base\Component |
canGetProperty() |
Returns a value indicating whether a property can be read. | yii\base\BaseObject |
canSetProperty() |
Returns a value indicating whether a property can be set. | yii\base\BaseObject |
className() |
Returns the fully qualified name of this class. | yii\base\BaseObject |
deleteTagGroupById() |
Deletes a tag group by its ID. | craft\services\Tags |
detachBehavior() |
Detaches a behavior from the component. | yii\base\Component |
detachBehaviors() |
Detaches all behaviors from the component. | yii\base\Component |
ensureBehaviors() |
Makes sure that the behaviors declared in behaviors() are attached to this component. | yii\base\Component |
getAllTagGroupIds() |
Returns all of the group IDs. | craft\services\Tags |
getAllTagGroups() |
Returns all tag groups. | craft\services\Tags |
getBehavior() |
Returns the named behavior object. | yii\base\Component |
getBehaviors() |
Returns all behaviors attached to this component. | yii\base\Component |
getTagById() |
Returns a tag by its ID. | craft\services\Tags |
getTagGroupByHandle() |
Gets a group by its handle. | craft\services\Tags |
getTagGroupById() |
Returns a group by its ID. | craft\services\Tags |
getTotalTagGroups() |
Gets the total number of tag groups. | craft\services\Tags |
hasEventHandlers() |
Returns a value indicating whether there is any handler attached to the named event. | yii\base\Component |
hasMethod() |
Returns a value indicating whether a method is defined. | yii\base\BaseObject |
hasProperty() |
Returns a value indicating whether a property is defined. | yii\base\BaseObject |
init() |
Initializes the object. | yii\base\BaseObject |
off() |
Detaches an existing event handler from this component. | yii\base\Component |
on() |
Attaches an event handler to an event. | yii\base\Component |
saveTagGroup() |
Saves a tag group. | craft\services\Tags |
trigger() |
Triggers an event. | yii\base\Component |
Event | Type | Description | Defined By |
---|---|---|---|
EVENT_AFTER_DELETE_GROUP |
craft\events\TagGroupEvent | The event that is triggered after a tag group is deleted. | craft\services\Tags |
EVENT_AFTER_SAVE_GROUP |
craft\events\TagGroupEvent | The event that is triggered after a tag group is saved. | craft\services\Tags |
EVENT_BEFORE_DELETE_GROUP |
craft\events\TagGroupEvent | The event that is triggered before a tag group is deleted. | craft\services\Tags |
EVENT_BEFORE_SAVE_GROUP |
craft\events\TagGroupEvent | The event that is triggered before a tag group is saved. | craft\services\Tags |
Method Details
deleteTagGroupById()
public method
#
Deletes a tag group by its ID.
public boolean deleteTagGroupById ( \craft\services\int $tagGroupId )
$tagGroupId |
integer | |
return | boolean | Whether the tag group was deleted successfully |
---|---|---|
throws | Throwable | if reasons |
getAllTagGroupIds()
public method
#
Returns all of the group IDs.
public array getAllTagGroupIds ( )
getAllTagGroups()
public method
#
Returns all tag groups.
public craft\models\TagGroup[] getAllTagGroups ( )
getTagById()
public method
#
Returns a tag by its ID.
public craft\elements\Tag, null getTagById ( \craft\services\int $tagId, \craft\services\int $siteId = null )
$tagId |
integer | |
$siteId |
integer, null |
getTagGroupByHandle()
public method
#
Gets a group by its handle.
public craft\models\TagGroup, null getTagGroupByHandle ( \craft\services\string $groupHandle )
$groupHandle |
string |
getTagGroupById()
public method
#
Returns a group by its ID.
public craft\models\TagGroup, null getTagGroupById ( \craft\services\int $groupId )
$groupId |
integer |
getTotalTagGroups()
public method
#
Gets the total number of tag groups.
public integer getTotalTagGroups ( )
saveTagGroup()
public method
#
Saves a tag group.
public boolean saveTagGroup ( craft\models\TagGroup $tagGroup, \craft\services\bool $runValidation = true )
$tagGroup |
craft\models\TagGroup | The tag group to be saved |
$runValidation |
boolean | Whether the tag group should be validated |
return | boolean | Whether the tag group was saved successfully |
---|---|---|
throws | craft\errors\TagGroupNotFoundException | if $tagGroup->id is invalid |
throws | Throwable | if reasons |
Event Details
EVENT_AFTER_DELETE_GROUP
event of type craft\events\TagGroupEvent
#
The event that is triggered after a tag group is deleted.
EVENT_AFTER_SAVE_GROUP
event of type craft\events\TagGroupEvent
#
The event that is triggered after a tag group is saved.
EVENT_BEFORE_DELETE_GROUP
event of type craft\events\TagGroupEvent
#
The event that is triggered before a tag group is deleted.
EVENT_BEFORE_SAVE_GROUP
event of type craft\events\TagGroupEvent
#
The event that is triggered before a tag group is saved.