3
0
Fork 0
mirror of https://github.com/farmOS/farmOS.git synced 2024-02-23 11:37:38 +01:00
farmOS/modules/core/id_tag/farm_id_tag.module

41 lines
915 B
PHP

<?php
/**
* @file
* ID tag module.
*/
/**
* Allowed values callback function for the ID tag type field.
*
* @param string $bundle
* The asset bundle to get allowed values for.
*
* @return array
* Returns an array of allowed values for use in form select options.
*/
function farm_id_tag_type_allowed_values($bundle) {
/** @var \Drupal\farm_id_tag\Entity\FarmIDTagTypeInterface[] $types */
$types = \Drupal::entityTypeManager()->getStorage('tag_type')->loadMultiple();
$allowed_values = [];
foreach ($types as $id => $type) {
$bundles = $type->getBundles();
if (empty($bundles) || in_array($bundle, $bundles)) {
$allowed_values[$id] = $type->getLabel();
}
}
return $allowed_values;
}
/**
* Implements hook_theme().
*/
function farm_id_tag_theme() {
return [
'field__id_tag' => [
'template' => 'field--id-tag',
'base hook' => 'field',
],
];
}