PHP Class Term

Inheritance: extends BaseModel
显示文件 Open project: croogo/croogo Class Usage Examples

Public Properties

Property Type Description
$actsAs array Behaviors used by the Model
$findMethods
$hasAndBelongsToMany array Model associations: hasAndBelongsToMany
$name string Model name
$validate array Validation

Public Methods

Method Description
add ( $data, $vocabularyId ) : array | boolean Save term
beforeDelete ( $cascade = true ) : boolean Allow delete on whether given Term has any association left with Taxonomy
edit ( $data, $vocabularyId ) : array | boolean Edit term
hasSlugChanged ( integer $id, string $slug ) : boolean Checks wether slug has changed for given Term id
isInVocabulary ( integer $id, integer $vocabularyId, integer $taxonomyId = null ) : boolean Convenience method to check whether term exists within a vocabulary
remove ( integer $id, integer $vocabularyId ) Remove term
saveAndGetId ( array $data ) : integer Save Term and return ID.
setScopeForTaxonomy ( integer $vocabularyId ) Set Scope
slugExists ( $slug ) : boolean Convenience check for slug

Protected Methods

Method Description
_findByVocabulary ( $state, $query, $results = [] )
_save ( array $data, integer $vocabularyId, integer $taxonomyId = null ) Save new/updated term data

Method Details

_findByVocabulary() protected method

protected _findByVocabulary ( $state, $query, $results = [] )

_save() protected method

Save new/updated term data
protected _save ( array $data, integer $vocabularyId, integer $taxonomyId = null )
$data array Term data
$vocabularyId integer Vocabulary Id
$taxonomyId integer Taxonomy Id

add() public method

Save term
See also: Term::_save()
public add ( $data, $vocabularyId ) : array | boolean
return array | boolean Array of saved term or boolean false

beforeDelete() public method

Allow delete on whether given Term has any association left with Taxonomy
public beforeDelete ( $cascade = true ) : boolean
return boolean

edit() public method

Edit term
See also: Term::_save()
public edit ( $data, $vocabularyId ) : array | boolean
return array | boolean Array of saved term or boolean false

hasSlugChanged() public method

Checks wether slug has changed for given Term id
public hasSlugChanged ( integer $id, string $slug ) : boolean
$id integer Term Id
$slug string Slug
return boolean True if slug has changed

isInVocabulary() public method

Convenience method to check whether term exists within a vocabulary
public isInVocabulary ( integer $id, integer $vocabularyId, integer $taxonomyId = null ) : boolean
$id integer Term Id
$vocabularyId integer Vocabulary Id
$taxonomyId integer Taxonomy Id
return boolean True if Term exists in Vocabulary

remove() public method

Remove term
public remove ( integer $id, integer $vocabularyId )
$id integer Term Id
$vocabularyId integer Vocabulary Id

saveAndGetId() public method

Save Term and return ID.
public saveAndGetId ( array $data ) : integer
$data array
return integer

setScopeForTaxonomy() public method

Set Scope
public setScopeForTaxonomy ( integer $vocabularyId )
$vocabularyId integer Vocabulary Id

slugExists() public method

Convenience check for slug
public slugExists ( $slug ) : boolean
return boolean

Property Details

$actsAs public_oe property

Behaviors used by the Model
public array $actsAs
return array

$findMethods public_oe property

public $findMethods

$hasAndBelongsToMany public_oe property

Model associations: hasAndBelongsToMany
public array $hasAndBelongsToMany
return array

$name public_oe property

Model name
public string $name
return string

$validate public_oe property

Validation
public array $validate
return array