Craft 2 Class Reference

Class TagModel

Package
craft.app.models
Namespace
Craft
Inheritance
class TagModel » BaseElementModel » BaseModel » \CModel » \CComponent
Implements
\ArrayAccess, \Traversable, \IteratorAggregate
Since
1.1
Source Code
craft/app/models/TagModel.php

Tag model class.

Public Properties
Property Type Description Defined By
allErrors array Returns all errors in a single, flattened list, devoid of attribute names. BaseModel
ancestors ElementCriteriaModel Returns the element's ancestors. BaseElementModel
attributeConfigs array Returns this model's normalized attribute configs. BaseModel
attributes array Returns an array of attribute values. BaseModel
children ElementCriteriaModel Returns the element's children. BaseElementModel
classHandle string Get the class name, sans namespace and suffix. BaseModel
content ContentModel Returns the content for the element. BaseElementModel
contentFromPost array Returns the raw content from the post data, before it was passed through prepValueFromPost(). BaseElementModel
contentPostLocation string / null Returns the location in POST that the content was pulled from. BaseElementModel
contentTable string Returns the name of the table this element's content is stored in. BaseElementModel
cpEditUrl string / false Returns the element's CP edit URL. BaseElementModel
descendants ElementCriteriaModel Returns the element's descendants. BaseElementModel
elementType string Returns the type of element this is. BaseElementModel
errors array Returns the errors for all attribute or a single attribute. \CModel
extraAttributeNames array Returns a list of the names of the extra attributes that have been saved on this model, if it's not strict. BaseModel
fieldColumnPrefix string Returns the field column prefix this element's content uses. BaseElementModel
fieldContext string Returns the field context this element's content uses. BaseElementModel
fieldLayout FieldLayoutModel / null Returns the field layout used by this element. TagModel
group TagGroupModel / null Returns the tag's group. TagModel
hasFreshContent bool Returns whether the element’s content is "fresh" (unsaved and without validation errors). BaseElementModel
iterator \CMapIterator Returns an iterator for traversing the attributes in the model. \CModel
locales array Returns the locale IDs this element is available in. BaseElementModel
name string Returns the tag's title. TagModel
next ElementCriteriaModel / null Returns the next element relative to this one, from a given set of criteria. BaseElementModel
nextSibling BaseElementModel / null Returns the element's next sibling. BaseElementModel
parent BaseElementModel / null Get the element's parent. BaseElementModel
parents ElementCriteriaModel Returns a new ElementCriteriaModel prepped to return this element's same-type parents. BaseElementModel
prev ElementCriteriaModel / null Returns the previous element relative to this one, from a given set of criteria. BaseElementModel
prevSibling BaseElementModel / null Returns the element's previous sibling. BaseElementModel
rawContent mixed Returns the raw content saved on this entity. BaseElementModel
ref string / null Returns the reference string to this element. BaseElementModel
safeAttributeNames array Returns the attribute names that are safe to be massively assigned. \CModel
scenario string Returns the scenario that this model is used in. \CModel
set TagGroupModel / null Returns the tag's group. TagModel
siblings ElementCriteriaModel Returns all of the element's siblings. BaseElementModel
status string / null Returns the element's status. BaseElementModel
thumbUrl string / null Returns the URL to the element's thumbnail, if there is one. BaseElementModel
title string Returns the element's title. BaseElementModel
totalDescendants bool Returns the total number of descendants that the element has. BaseElementModel
url string Returns the element's full URL. BaseElementModel
urlFormat string / null Returns the URL format used to generate this element's URL. BaseElementModel
validatorList \CList Returns all the validators declared in the model. \CModel
validators array Returns the validators applicable to the current scenario. \CModel
Protected Properties
Property Type Description Defined By
classSuffix string BaseModel
strictAttributes bool Whether this model should be strict about only allowing values to be set on defined attributes BaseModel
Public Methods
Method Description Defined By
__call() Magic __call() method, used for chain-setting attribute values. BaseModel
__construct() Constructor BaseModel
__get() Getter BaseElementModel
__isset() Treats custom fields as properties. BaseElementModel
__set() PHP setter magic method. BaseModel
__toString() Use the tag title as its string representation. TagModel
__unset() Sets a component property to be null. \CComponent
addError() Adds a new error to the specified attribute. \CModel
addErrors() Adds a list of errors. \CModel
asa() Returns the named behavior object. \CComponent
attachBehavior() Attaches a behavior to this component. \CComponent
attachBehaviors() Attaches a list of behaviors to the component. \CComponent
attachEventHandler() Attaches an event handler to an event. \CComponent
attributeLabels() Returns the attribute labels. BaseModel
attributeNames() Returns the list of this model's attribute names. BaseModel
behaviors() Returns a list of behaviors that this model should behave as. \CModel
canGetProperty() Determines whether a property can be read. \CComponent
canSetProperty() Determines whether a property can be set. \CComponent
clearErrors() Removes errors for all attributes or a single attribute. \CModel
copy() Returns a copy of this model. BaseModel
createValidators() Creates validator objects based on the specification in rules. \CModel
detachBehavior() Detaches a behavior from the component. \CComponent
detachBehaviors() Detaches all behaviors from the component. \CComponent
detachEventHandler() Detaches an existing event handler. \CComponent
disableBehavior() Disables an attached behavior. \CComponent
disableBehaviors() Disables all behaviors attached to this component. \CComponent
enableBehavior() Enables an attached behavior. \CComponent
enableBehaviors() Enables all behaviors attached to this component. \CComponent
evaluateExpression() Evaluates a PHP expression or callback under the context of this component. \CComponent
generateAttributeLabel() Generates a user friendly attribute label. This is done by replacing underscores or dashes with blanks and changing the first letter of each word to upper case. For example, 'department_name' or 'DepartmentName' becomes 'Department Name'. BaseModel
getAllErrors() Returns all errors in a single, flattened list, devoid of attribute names. BaseModel
getAncestors() Returns the element's ancestors. BaseElementModel
getAttribute() Gets an attribute’s value. BaseElementModel
getAttributeConfigs() Returns this model's normalized attribute configs. BaseModel
getAttributeLabel() Returns the text label for the specified attribute. \CModel
getAttributes() Returns an array of attribute values. BaseModel
getChildren() Returns the element's children. BaseElementModel
getClassHandle() Get the class name, sans namespace and suffix. BaseModel
getContent() Returns the content for the element. BaseElementModel
getContentFromPost() Returns the raw content from the post data, before it was passed through prepValueFromPost(). BaseElementModel
getContentPostLocation() Returns the location in POST that the content was pulled from. BaseElementModel
getContentTable() Returns the name of the table this element's content is stored in. BaseElementModel
getCpEditUrl() Returns the element's CP edit URL. BaseElementModel
getDescendants() Returns the element's descendants. BaseElementModel
getEagerLoadedElements() Returns some eager-loaded elements on a given handle. BaseElementModel
getElementType() Returns the type of element this is. BaseElementModel
getError() Returns the first error of the specified attribute. \CModel
getErrors() Returns the errors for all attribute or a single attribute. \CModel
getEventHandlers() Returns the list of attached event handlers for an event. \CComponent
getExtraAttributeNames() Returns a list of the names of the extra attributes that have been saved on this model, if it's not strict. BaseModel
getFieldColumnPrefix() Returns the field column prefix this element's content uses. BaseElementModel
getFieldContext() Returns the field context this element's content uses. BaseElementModel
getFieldLayout() Returns the field layout used by this element. TagModel
getFieldValue() Returns the prepped content for a given field. BaseElementModel
getGroup() Returns the tag's group. TagModel
getHasFreshContent() Returns whether the element’s content is "fresh" (unsaved and without validation errors). BaseElementModel
getIterator() Returns an iterator for traversing the attributes in the model. \CModel
getLocales() Returns the locale IDs this element is available in. BaseElementModel
getName() Returns the tag's title. TagModel
getNext() Returns the next element relative to this one, from a given set of criteria. BaseElementModel
getNextSibling() Returns the element's next sibling. BaseElementModel
getParent() Get the element's parent. BaseElementModel
getParents() Returns a new ElementCriteriaModel prepped to return this element's same-type parents. BaseElementModel
getPrev() Returns the previous element relative to this one, from a given set of criteria. BaseElementModel
getPrevSibling() Returns the element's previous sibling. BaseElementModel
getRawContent() Returns the raw content saved on this entity. BaseElementModel
getRef() Returns the reference string to this element. BaseElementModel
getSafeAttributeNames() Returns the attribute names that are safe to be massively assigned. \CModel
getScenario() Returns the scenario that this model is used in. \CModel
getSet() Returns the tag's group. TagModel
getSiblings() Returns all of the element's siblings. BaseElementModel
getStatus() Returns the element's status. BaseElementModel
getThumbUrl() Returns the URL to the element's thumbnail, if there is one. BaseElementModel
getTitle() Returns the element's title. BaseElementModel
getTotalDescendants() Returns the total number of descendants that the element has. BaseElementModel
getUrl() Returns the element's full URL. BaseElementModel
getUrlFormat() Returns the URL format used to generate this element's URL. BaseElementModel
getValidatorList() Returns all the validators declared in the model. \CModel
getValidators() Returns the validators applicable to the current scenario. \CModel
hasDescendants() Returns whether the element has descendants. BaseElementModel
hasEagerLoadedElements() Returns whether elements have been eager-loaded with a given handle. BaseElementModel
hasErrors() Returns a value indicating whether there is any validation error. \CModel
hasEvent() Determines whether an event is defined. \CComponent
hasEventHandler() Checks whether the named event has attached handlers. \CComponent
hasProperty() Determines whether a property is defined. \CComponent
isAncestorOf() Returns whether this element is an ancestor of another one. BaseElementModel
isAttributeRequired() Returns a value indicating whether the attribute is required. \CModel
isAttributeSafe() Returns a value indicating whether the attribute is safe for massive assignments. \CModel
isChildOf() Returns whether this element is a direct child of another one. BaseElementModel
isDescendantOf() Returns whether this element is a descendant of another one. BaseElementModel
isEditable() Returns whether the current user can edit the element. TagModel
isNextSiblingOf() Returns whether this element is the direct next sibling of another one. BaseElementModel
isParentOf() Returns whether this element is a direct parent of another one. BaseElementModel
isPrevSiblingOf() Returns whether this element is the direct previous sibling of another one. BaseElementModel
isSiblingOf() Returns whether this element is a sibling of another one. BaseElementModel
offsetExists() Treats custom fields as array offsets. BaseElementModel
offsetGet() Returns the element at the specified offset. \CModel
offsetSet() Sets the element at the specified offset. \CModel
offsetUnset() Unsets the element at the specified offset. \CModel
onAfterConstruct() This event is raised after the model instance is created by new operator. \CModel
onAfterValidate() This event is raised after the validation is performed. \CModel
onBeforeValidate() This event is raised before the validation is performed. \CModel
onUnsafeAttribute() This method is invoked when an unsafe attribute is being massively assigned. \CModel
populateModel() Populates a new model instance with a given set of attributes. BaseElementModel
populateModels() Mass-populates models based on an array of attribute arrays. BaseModel
raiseEvent() Raises an event. \CComponent
rules() Returns this model's validation rules. BaseModel
setAttribute() Sets an attribute's value. BaseModel
setAttributes() Sets multiple attribute values at once. BaseModel
setContent() Sets the content for the element. BaseElementModel
setContentFromPost() Sets the content from post data, calling prepValueFromPost() on the field types. BaseElementModel
setContentPostLocation() Sets the location in POST that the content was pulled from. BaseElementModel
setEagerLoadedElements() Sets some eager-loaded elements on a given handle. BaseElementModel
setId() Returns the tag group's ID. TagModel
setNext() Sets the default next element. BaseElementModel
setParent() Sets the element's parent. BaseElementModel
setPrev() Sets the default previous element. BaseElementModel
setRawPostContent() Sets a field’s raw post content. BaseElementModel
setScenario() Sets the scenario for the model. \CModel
unsetAttributes() Sets the attributes to be null. \CModel
validate() Validates all of the attributes for the current Model. Any attributes that fail validation will additionally get logged to the craft/storage/runtime/logs folder with a level of LogLevel::Warning. BaseModel
Protected Methods
Method Description Defined By
afterConstruct() This method is invoked after a model instance is created by new operator. \CModel
afterValidate() This method is invoked after validation ends. \CModel
beforeValidate() This method is invoked before validation starts. \CModel
createContent() Creates the content model associated with this element. BaseElementModel
defineAttributes() Defines this model's attributes. TagModel
getFieldByHandle() Returns the field with a given handle. BaseElementModel
Events
Event Description Defined By
onAfterConstruct This event is raised after the model instance is created by new operator. \CModel
onBeforeValidate This event is raised before the validation is performed. \CModel
onAfterValidate This event is raised after the validation is performed. \CModel
onUnsafeAttribute This method is invoked when an unsafe attribute is being massively assigned. \CModel

Property Details

fieldLayout public property #

Returns the field layout used by this element.

public FieldLayoutModel|null getFieldLayout()

group public property #

Returns the tag's group.

public TagGroupModel|null getGroup()

name public property #

Returns the tag's title.

Deprecated in 2.3. Use $title instead.

public string getName(bool $logDeprecationError = true)

set public property #

Returns the tag's group.

Deprecated in 2.0. Use getGroup() instead.

public TagGroupModel|null getSet()

Method Details

__toString() public method #

Use the tag title as its string representation.

public string __toString()
Returns string

defineAttributes() protected method #

Defines this model's attributes.

protected array defineAttributes()
Returns array

getAttribute() public method #

Gets an attribute’s value.

public mixed getAttribute(string $name, bool $flattenValue = false)
$name string The attribute’s name.
$flattenValue bool
Returns mixed

getFieldLayout() public method #

Returns the field layout used by this element.

public FieldLayoutModel|null getFieldLayout()
Returns FieldLayoutModel / null

getGroup() public method #

Returns the tag's group.

public TagGroupModel|null getGroup()
Returns TagGroupModel / null

getName() public method #

Returns the tag's title.

Deprecated in 2.3. Use $title instead.

public string getName(bool $logDeprecationError = true)
$logDeprecationError bool
Returns string

getSet() public method #

Returns the tag's group.

Deprecated in 2.0. Use getGroup() instead.

public TagGroupModel|null getSet()
Returns TagGroupModel / null

isEditable() public method #

Returns whether the current user can edit the element.

public bool isEditable()
Returns bool

populateModel() public static method #

Populates a new model instance with a given set of attributes.

public static BaseModel populateModel(mixed $values)
$values mixed
Returns BaseModel

setId() public method #

Returns the tag group's ID.

Deprecated in 2.0. Use 'groupId' instead.

public int|null setId()
Returns int / null