public function BlogapiCommunicator::getCtVocabularies in Blog API 8
Returns all the vocabularies whose terms that can be stored in a CT.
Parameters
$ct: Content type machine name.
Return value
array An array of vocabularies.
1 call to BlogapiCommunicator::getCtVocabularies()
- BlogapiCommunicator::getCategoryList in src/
BlogapiCommunicator.php - Returns a list of available categories on a content type.
File
- src/
BlogapiCommunicator.php, line 281
Class
- BlogapiCommunicator
- Class BlogapiCommunicator.
Namespace
Drupal\blogapiCode
public function getCtVocabularies($ct) {
$definitions = $this->entityFieldManager
->getFieldDefinitions('node', $ct);
$vocabs = [];
foreach ($definitions as $field) {
if ($this
->fieldIsTaxonomy($field)) {
// Get the field handler setting from which
// we determine supported vocabulary bundles.
$settings = $field
->getSetting('handler_settings');
if (!empty($settings['target_bundles'])) {
foreach ($settings['target_bundles'] as $target) {
// If the vocabulary is not already in the return array.
if (!in_array($target, $vocabs)) {
$vocabs[] = $target;
}
}
}
}
}
return $vocabs;
}