Defines a vocabulary term object.
◆ __construct()
| Drupal\tripal\TripalVocabTerms\TripalTerm::__construct |
( |
?array |
$details = NULL | ) |
|
Constructs a new term object.
Either use the set functions of this object to provide the necessary values or provide them using the $details argument.
Use the isValid() function to make sure the term is valid before saving. A term must have the following values set to be valid: name, idSpace, vocabulary, and accession.
The $details argument accepts the following keys and values
- name: (string) the name of the term
- definition: (string) the definitino for the term
- is_obsolete: (bool) True if the term is obsolete. Default is False.
- is_relationship_type: (bool) True if the term is a relationship type. Default is False.
- idSpace: (array) the ID space name.
- vocabulary: (array) the vocabulary name.
- parents: (array) an array of parents where each element in the array is a tuple of two values: a TripalTerm for the parent and a second TripalTerm for the relationship.
- altIDs: (array) an array of alternate term IDs where each element is a tuple of two values: the ID space name and the accession of the alternate term.
- synonyms: (array) an array of synonyms where each element is the synonym, or a list of typles containng the synonym followed by the a TripalTerm for the synonym type. Usually the synonym types are terms with a name of: 'exact', 'broad', 'narrow' or 'related'.
- properties:(array) an array of properties where each element is a tuple of two values: a TriaplTerm for the property type and a value. If the same property is used multiple times with different values, then the rank will be set in the order that they are provided.
- Parameters
-
| array | null | $details | The name. |
◆ addAltId()
| Drupal\tripal\TripalVocabTerms\TripalTerm::addAltId |
( |
string |
$idSpace, |
|
|
string |
$accession |
|
) |
| |
Adds an alternative term ID for this term.
- Parameters
-
| string | $idSpace | The ID space name of the parent term. |
| string | $accession | The accession for the parent term. |
◆ addParent()
| Drupal\tripal\TripalVocabTerms\TripalTerm::addParent |
( |
TripalTerm |
$parent, |
|
|
TripalTerm |
$relationship |
|
) |
| |
Adds a parent term.
A term may have zero or more parents. A term without parents will be considered a root term. The relationship between the child term and the parent must be specified by another term indicating the relationship (e.g. is_a, derives_from, etc).
- Parameters
-
| Drupal\tripal\TripalVocabTerms\TripalTerm | $parent | The parent term or NULL. |
| Drupal\tripal\TripalVocabTerms\TripalTerm | $relationship | The relationship term or NULL. |
- Returns
- bool True on success or false otherwise.
◆ addProperty()
| Drupal\tripal\TripalVocabTerms\TripalTerm::addProperty |
( |
TripalTerm |
$term, |
|
|
string |
$value, |
|
|
?int |
$rank = NULL |
|
) |
| |
Adds a property to this term.
- Parameters
-
| TripalTerm | $term | A term indicating the propery type. |
| string | $value | The value of the property. |
| int | null | $rank | The rank (or order) of the value. If no rank is specified and if a property of the same term is already present then the rank will be incremented for the next value added. |
- Returns
- bool True if the property was successfully added, False otherwise.
◆ addSynonym()
| Drupal\tripal\TripalVocabTerms\TripalTerm::addSynonym |
( |
string |
$synonym, |
|
|
?TripalTerm |
$type = NULL |
|
) |
| |
Adds a synonym for this term.
Some terms may have synonymous names. The synonym type is usually one of the of the following terms: 'exact', 'broad', 'narrow', or 'related'.
It is highly encouraged to always provide a type for the synonym.
- Parameters
-
| string | $synonym | The synonym. |
| Drupal\tripal\TripalVocabTerms\TripalTerm | $type | An optional Tripal term indicating the type of synonym. |
◆ getAccession()
| Drupal\tripal\TripalVocabTerms\TripalTerm::getAccession |
( |
| ) |
|
Returns this term's accession.
- Returns
- string The accession.
◆ getAltIds()
| Drupal\tripal\TripalVocabTerms\TripalTerm::getAltIds |
( |
| ) |
|
Returns the list of alternate IDs for this term.
- Returns
- array An array of term ID strings.
◆ getDefinition()
| Drupal\tripal\TripalVocabTerms\TripalTerm::getDefinition |
( |
| ) |
|
Returns this term's definition.
- Returns
- string The definition.
◆ getIdSpace()
| Drupal\tripal\TripalVocabTerms\TripalTerm::getIdSpace |
( |
| ) |
|
Returns this term's id space collection name.
- Returns
- string The id space collection name.
◆ getIdSpaceObject()
| Drupal\tripal\TripalVocabTerms\TripalTerm::getIdSpaceObject |
( |
| ) |
|
Returns an instance of this term's id space.
- Returns
- Drupal\tripal\TripalVocabTerms\Interfaces\TripalIdSpaceInterface The id space instance.
◆ getInternalId()
| Drupal\tripal\TripalVocabTerms\TripalTerm::getInternalId |
( |
| ) |
|
Gets the internal ID of this term. The default is NULL.
- Returns
- mixed The internal ID.
◆ getLoadedAttributes()
| Drupal\tripal\TripalVocabTerms\TripalTerm::getLoadedAttributes |
( |
| ) |
|
Indicates which attributes are loaded.
A term may have any number of attributes that may or may not be loaded. The array returned by this function will indicatew which attributes are loaded and which are not. The array keys are the attribute names and the value is a boolean indicating if the attribute has been loaded. If all attributes are true then all all ahve been loaded and the term is complete. If some attributes are False then the term is not complete.
- Returns
- array An associative array with keys indicating the attributes and the value being a boolean where True indicates that the attribute is laoded and False otherwise.
◆ getName()
| Drupal\tripal\TripalVocabTerms\TripalTerm::getName |
( |
| ) |
|
Returns this term's name.
- Returns
- string The name.
◆ getParents()
| Drupal\tripal\TripalVocabTerms\TripalTerm::getParents |
( |
| ) |
|
Returns the parents for this term.
- Returns
- array In the array, the key is the term ID for the parent (e.g. GO:0008150). The value is a tuple that should contain as its first element the parent term and the second element the relationship term.
◆ getProperties()
| Drupal\tripal\TripalVocabTerms\TripalTerm::getProperties |
( |
| ) |
|
Retrieves the list of properties for this term.
- Returns
- array An associative array where the
- first level key is the term_id for the property.
- second level key is the rank and the value is a tuple with the first element being the TripalTerm for the property type and the second being the propertly value.
◆ getSynonyms()
| Drupal\tripal\TripalVocabTerms\TripalTerm::getSynonyms |
( |
| ) |
|
Returns the list of synonyms for this term.
- Returns
- array An associative array where the keys are the synonyms and the values the synonym type TripalTerm.
◆ getTermId()
| Drupal\tripal\TripalVocabTerms\TripalTerm::getTermId |
( |
| ) |
|
Retrieves the ID for this term.
The term ID is the combination of the ID space and the accession (e.g. GO:0008150).
- Returns
- string The term ID.
◆ getURL()
| Drupal\tripal\TripalVocabTerms\TripalTerm::getURL |
( |
| ) |
|
Returns this term's URL.
- Returns
- string The URL.
◆ getVocabulary()
| Drupal\tripal\TripalVocabTerms\TripalTerm::getVocabulary |
( |
| ) |
|
Returns this term's default vocabulary collection name.
- Returns
- string The vocabulary collection name.
◆ getVocabularyObject()
| Drupal\tripal\TripalVocabTerms\TripalTerm::getVocabularyObject |
( |
| ) |
|
Returns an instance of this term's vocabulary.
- Returns
- Drupal\tripal\TripalVocabTerms\Interfaces\TripalVocabularyInterface The vocabulary instance.
◆ isEqual()
| Drupal\tripal\TripalVocabTerms\TripalTerm::isEqual |
( |
TripalTerm |
$other | ) |
|
Tests if the given term is equal to this term.
- Parameters
-
| Drupal\tripal\TripalVocabTerms\TripalTerm | $other | The other given term. |
- Returns
- bool True if equal otherwise false.
◆ isObsolete()
| Drupal\tripal\TripalVocabTerms\TripalTerm::isObsolete |
( |
| ) |
|
Indicates if this term is obsolete or not.
- Returns
- bool True if the term is obsolete, False otherwise.
◆ isRelationshipType()
| Drupal\tripal\TripalVocabTerms\TripalTerm::isRelationshipType |
( |
| ) |
|
Indicates if the term is a relationship type term.
- Returns
- bool True if the term is a relationship type, False otherwise.
◆ isValid()
| Drupal\tripal\TripalVocabTerms\TripalTerm::isValid |
( |
| ) |
|
Indicates if this term is valid and can be saved.
- Returns
- bool True if valid, False otherwise.
◆ removeAltId()
| Drupal\tripal\TripalVocabTerms\TripalTerm::removeAltId |
( |
string |
$idSpace, |
|
|
string |
$accession |
|
) |
| |
Removes an alternate ID from this term.
- Parameters
-
| string | $idSpace | The ID space name of the parent term. |
| string | $accession | The accession for the parent term. |
- Returns
- bool True on success or false otherwise.
◆ removeParent()
| Drupal\tripal\TripalVocabTerms\TripalTerm::removeParent |
( |
string |
$idSpace, |
|
|
string |
$accession |
|
) |
| |
Removes a parent from the term.
- Parameters
-
| string | $idSpace | The ID space name of the parent term. |
| string | $accession | The accession for the parent term. |
- Returns
- bool True on success or false otherwise.
◆ removeProperty()
| Drupal\tripal\TripalVocabTerms\TripalTerm::removeProperty |
( |
string |
$idSpace, |
|
|
string |
$accession, |
|
|
int |
$rank |
|
) |
| |
Removes a property from the list of properties.
- Parameters
-
| string | $idSpace | The ID space name of the property term. |
| string | $accession | The accession for the property term. |
| int | $rank | The rank of the value to remove. |
- Returns
- bool True on success or false otherwise.
◆ removeSynonym()
| Drupal\tripal\TripalVocabTerms\TripalTerm::removeSynonym |
( |
string |
$synonym | ) |
|
Removes a synonym from this term.
- Parameters
-
| string | $synonym | The synonym. |
- Returns
- bool True on success or false otherwise.
◆ save()
| Drupal\tripal\TripalVocabTerms\TripalTerm::save |
( |
|
$options | ) |
|
Saves a term to its ID space data store.
If a term is new in the ID space and has no parents then it will be considered a "root" term for the vocabulary. If the term has parents, use the addParents() function to add them before calling this function. If the term is not new and already exists you only need to provide parents if you need to change the parentage. If the updateParent option is True then all parents of an existing term will be removed and will be updated to the parents provided. If updateParent is False and no parents are provided then no change is made to the parent relationships.
The options array accepts the following recognized keys:
failIfExists(boolean): True to force this method to fail if this term already exists else false to update this term if it already exists. The default is false.
updateParent(boolean): True to update this term's parent to the one given or false to not update this existing term's parent. If this term is new this has no effect. The default is false.
- Parameters
-
| array | $options | The options array. |
- Returns
- bool True on success or false otherwise.
◆ setAccession()
| Drupal\tripal\TripalVocabTerms\TripalTerm::setAccession |
( |
|
$accession | ) |
|
Sets this term's accession.
- Parameters
-
| string | $accession | The accession. |
◆ setDefinition()
| Drupal\tripal\TripalVocabTerms\TripalTerm::setDefinition |
( |
string |
$definition | ) |
|
Sets the term's description.
- Parameters
-
| string | $definition | The definition for this term. |
◆ setIdSpace()
| Drupal\tripal\TripalVocabTerms\TripalTerm::setIdSpace |
( |
string |
$idSpace | ) |
|
Sets the ID space for the term.
- Parameters
-
| string | $idSpace | The name of the ID space. |
◆ setIdSpacePlugin()
| Drupal\tripal\TripalVocabTerms\TripalTerm::setIdSpacePlugin |
( |
string |
$id_space_plugin_id | ) |
|
Sets the ID space plugin for the term.
- Parameters
-
| string | $id_space_plugin_id | The name of the ID space plugin, e.g. "chado_id_space". |
◆ setInternalId()
| Drupal\tripal\TripalVocabTerms\TripalTerm::setInternalId |
( |
|
$internalId | ) |
|
Sets the internal ID of this term to the given internal ID.
- Parameters
-
| mixed | $internalId | The internal ID. |
◆ setIsObsolete()
| Drupal\tripal\TripalVocabTerms\TripalTerm::setIsObsolete |
( |
bool |
$is_obsolete | ) |
|
Sets if the term is obsolete or not.
- Parameters
-
| bool | $is_obsolete | True if the term is obsolete, False otherwise. |
◆ setIsRelationshipType()
| Drupal\tripal\TripalVocabTerms\TripalTerm::setIsRelationshipType |
( |
bool |
$is_relationship_type | ) |
|
Sets if the term is a relationship type term.
- Parameters
-
| bool | $is_relationship_type | True if the term is a relationship type, False otherwise. |
◆ setName()
| Drupal\tripal\TripalVocabTerms\TripalTerm::setName |
( |
|
$name | ) |
|
Sets this term's name to the given name.
- Parameters
-
◆ setVocabulary()
| Drupal\tripal\TripalVocabTerms\TripalTerm::setVocabulary |
( |
string |
$vocabulary | ) |
|
Sets the vocabulary for the term.
- Parameters
-
| string | $vocabulary | The name of the vocabulary. |
◆ setVocabularyPlugin()
| Drupal\tripal\TripalVocabTerms\TripalTerm::setVocabularyPlugin |
( |
string |
$vocabulary_plugin_id | ) |
|
Sets the vocabulary plugin for the term.
- Parameters
-
| string | $vocabulary_plugin_id | The name of the vocabulary plugin, e.g. "chado_vocabulary". |
◆ suggestTerms()
| static Drupal\tripal\TripalVocabTerms\TripalTerm::suggestTerms |
( |
string |
$partial, |
|
|
int |
$max = 10 |
|
) |
| |
|
static |
Suggests valid terms based off matches from the given partial term name.
Note: A given max number of terms are returned.
- Parameters
-
| string | $partial | The partial term name. |
| int | $max | The given max number returned. |
- Returns
- array An array of valid Drupal\tripal\TripalVocabTerms\Term objects.
The documentation for this class was generated from the following file:
- tripal/src/TripalVocabTerms/TripalTerm.php