2020-10-14 16:46:01 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* ID tag module.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Allowed values callback function for the ID tag type field.
|
2020-10-14 16:56:15 +02:00
|
|
|
*
|
2020-10-15 19:40:46 +02:00
|
|
|
* @param string $bundle
|
|
|
|
* The asset bundle to get allowed values for.
|
|
|
|
*
|
2020-10-14 16:56:15 +02:00
|
|
|
* @return array
|
|
|
|
* Returns an array of allowed values for use in form select options.
|
2020-10-14 16:46:01 +02:00
|
|
|
*/
|
2020-10-15 19:40:46 +02:00
|
|
|
function farm_id_tag_type_allowed_values($bundle) {
|
2020-10-14 16:46:01 +02:00
|
|
|
/** @var \Drupal\farm_id_tag\Entity\FarmIDTagTypeInterface[] $types */
|
|
|
|
$types = \Drupal::entityTypeManager()->getStorage('tag_type')->loadMultiple();
|
|
|
|
$allowed_values = [];
|
|
|
|
foreach ($types as $id => $type) {
|
2020-10-15 19:40:46 +02:00
|
|
|
$bundles = $type->getBundles();
|
|
|
|
if (empty($bundles) || in_array($bundle, $bundles)) {
|
|
|
|
$allowed_values[$id] = $type->getLabel();
|
|
|
|
}
|
2020-10-14 16:46:01 +02:00
|
|
|
}
|
|
|
|
return $allowed_values;
|
|
|
|
}
|