DropdownService
in package
Dropdown Service — column-aware validation and resolution.
Bridges the ahg_dropdown table with ahg_dropdown_column_map to provide:
- Column → taxonomy mapping (which dropdown controls which column)
- Value validation against dropdown values
- Label resolution for display
- Bulk validation for imports/migrations
This replaces all hardcoded ENUM values with database-driven dropdowns managed via Admin > AHG Settings > Dropdown Manager.
Tags
Table of Contents
Methods
- clearCache() : void
- Clear all caches.
- getChoices() : array<string|int, mixed>
- Get valid values as [code => label] for a taxonomy.
- getChoicesForColumn() : array<string|int, mixed>
- Get valid values as [code => label] for a column.
- getChoicesWithAttributes() : array<string|int, mixed>
- Get choices with full attributes (code, label, color, icon).
- getDefault() : string|null
- Get the default value for a column.
- getDefaultForTaxonomy() : string|null
- Get the default value code for a taxonomy.
- getMappingsForTable() : array<string|int, mixed>
- Get all column mappings for a table.
- getStats() : array<string|int, mixed>
- Get statistics about dropdown coverage.
- getTaxonomy() : string|null
- Get the taxonomy name for a table.column.
- getValidValues() : array<string|int, mixed>
- Get all valid value codes for a taxonomy.
- isMapped() : bool
- Check if a column is mapped to a dropdown.
- isStrict() : bool
- Check if a column is strict (only dropdown values allowed).
- isValid() : bool
- Validate a value against the dropdown for a column.
- isValidForTaxonomy() : bool
- Validate a value directly against a taxonomy.
- resolveColor() : string|null
- Resolve a code to its color for a taxonomy.
- resolveLabel() : string|null
- Resolve a code to its display label for a column.
- resolveLabelForTaxonomy() : string|null
- Resolve a code to its display label for a taxonomy.
- validateRow() : array<string|int, mixed>
- Validate multiple values for a table row.
Methods
clearCache()
Clear all caches.
public
static clearCache() : void
getChoices()
Get valid values as [code => label] for a taxonomy.
public
static getChoices(string $taxonomy[, bool $includeEmpty = true ]) : array<string|int, mixed>
Parameters
- $taxonomy : string
- $includeEmpty : bool = true
Return values
array<string|int, mixed>getChoicesForColumn()
Get valid values as [code => label] for a column.
public
static getChoicesForColumn(string $table, string $column[, bool $includeEmpty = true ]) : array<string|int, mixed>
Parameters
- $table : string
- $column : string
- $includeEmpty : bool = true
Return values
array<string|int, mixed>getChoicesWithAttributes()
Get choices with full attributes (code, label, color, icon).
public
static getChoicesWithAttributes(string $taxonomy) : array<string|int, mixed>
Parameters
- $taxonomy : string
Return values
array<string|int, mixed>getDefault()
Get the default value for a column.
public
static getDefault(string $table, string $column) : string|null
Parameters
- $table : string
- $column : string
Return values
string|nullgetDefaultForTaxonomy()
Get the default value code for a taxonomy.
public
static getDefaultForTaxonomy(string $taxonomy) : string|null
Parameters
- $taxonomy : string
Return values
string|nullgetMappingsForTable()
Get all column mappings for a table.
public
static getMappingsForTable(string $table) : array<string|int, mixed>
Parameters
- $table : string
Return values
array<string|int, mixed>getStats()
Get statistics about dropdown coverage.
public
static getStats() : array<string|int, mixed>
Return values
array<string|int, mixed>getTaxonomy()
Get the taxonomy name for a table.column.
public
static getTaxonomy(string $table, string $column) : string|null
Parameters
- $table : string
- $column : string
Return values
string|nullgetValidValues()
Get all valid value codes for a taxonomy.
public
static getValidValues(string $taxonomy) : array<string|int, mixed>
Parameters
- $taxonomy : string
Return values
array<string|int, mixed>isMapped()
Check if a column is mapped to a dropdown.
public
static isMapped(string $table, string $column) : bool
Parameters
- $table : string
- $column : string
Return values
boolisStrict()
Check if a column is strict (only dropdown values allowed).
public
static isStrict(string $table, string $column) : bool
Parameters
- $table : string
- $column : string
Return values
boolisValid()
Validate a value against the dropdown for a column.
public
static isValid(string $table, string $column, string|null $value) : bool
Returns true if valid, false if invalid. Returns true for unmapped columns or non-strict columns with any value.
Parameters
- $table : string
- $column : string
- $value : string|null
Return values
boolisValidForTaxonomy()
Validate a value directly against a taxonomy.
public
static isValidForTaxonomy(string $taxonomy, string|null $value) : bool
Parameters
- $taxonomy : string
- $value : string|null
Return values
boolresolveColor()
Resolve a code to its color for a taxonomy.
public
static resolveColor(string $taxonomy, string $code) : string|null
Parameters
- $taxonomy : string
- $code : string
Return values
string|nullresolveLabel()
Resolve a code to its display label for a column.
public
static resolveLabel(string $table, string $column, string|null $code) : string|null
Parameters
- $table : string
- $column : string
- $code : string|null
Return values
string|nullresolveLabelForTaxonomy()
Resolve a code to its display label for a taxonomy.
public
static resolveLabelForTaxonomy(string $taxonomy, string|null $code) : string|null
Parameters
- $taxonomy : string
- $code : string|null
Return values
string|nullvalidateRow()
Validate multiple values for a table row.
public
static validateRow(string $table, array<string|int, mixed> $row) : array<string|int, mixed>
Returns array of invalid columns with details.
Parameters
- $table : string
- $row : array<string|int, mixed>