public static function Vocabularies::loadByMachineName in Hook Update Deploy Tools 7
Load a Vocabulary from its machine name.
Parameters
string $vocabulary_machine_name: The human readable name of a Vocabulary.
bool $strict: Flag to cause exception to be thrown if not able to load.
Return value
object The Vocabulary object if found.
Throws
\HudtException if it can not be found.
3 calls to Vocabularies::loadByMachineName()
- Terms::createNewTerm in src/
Terms.php - Create a Term from the imported object.
- Terms::export in src/
Terms.php - Exports a single term based on its tid. (Typically called from Drush).
- Terms::loadByName in src/
Terms.php - Load a term by name.
File
- src/
Vocabularies.php, line 213
Class
- Vocabularies
- Public methods for dealing with Vocabularies.
Namespace
HookUpdateDeployToolsCode
public static function loadByMachineName($vocabulary_machine_name, $strict = FALSE) {
Check::canUse('taxonomy');
Check::canCall('taxonomy_vocabulary_machine_name_load');
Check::notEmpty('vocabulary_machine_name', $vocabulary_machine_name);
// Grab all the Vocabularies.
$vocabulary = taxonomy_vocabulary_machine_name_load($vocabulary_machine_name);
if (!empty($vocabulary)) {
return $vocabulary;
}
else {
// Vocabulary not found.
if ($strict) {
// The Vocabulary was not found, throw exception, call this a failure.
$message = "There is no Vocabulary with machine name '@!name'. It could not be loaded.";
$variables = array(
'@name' => $vocabulary_machine_name,
);
throw new HudtException($message, $variables, WATCHDOG_ERROR, TRUE);
}
else {
return FALSE;
}
}
}