objectId || !$definition->contentType) { return $fields; } $taxConfig = $this->getTaxonomyConfig($definition->contentType); if (empty($taxConfig)) { return $fields; } // Auto-include employees from associated content types if (!empty($taxConfig['for_content'])) { $employees = $this->buildEmployeeRefs($definition, $taxConfig['for_content']); if (!empty($employees)) { $fields['employee'] = $employees; } } return $fields; } /** * Build Person references for employees from associated post types. * * For a tattoo shop term, this finds all artists (posts) tagged with this shop. */ private function buildEmployeeRefs(SchemaDefinition $definition, array $postTypes): array { $allRefs = []; foreach ($postTypes as $postType) { $fullType = str_starts_with($postType, BASE) ? $postType : BASE . $postType; $refs = SchemaReferenceBuilder::buildFromTerm( $definition->objectId, $fullType, 10, null, true ); if (!empty($refs)) { $allRefs = array_merge($allRefs, $refs); } } return $allRefs; } /** * Get taxonomy config from JVB_TAXONOMY constant. */ private function getTaxonomyConfig(string $contentType): array { if (!defined('JVB_TAXONOMY')) { return []; } $slug = jvbNoBase($contentType); return JVB_TAXONOMY[$slug] ?? []; } }