| 1: | <?php |
| 2: | |
| 3: | declare(strict_types=1); |
| 4: | |
| 5: | namespace LaravelUi5\OData\Edm\Vocabularies; |
| 6: | |
| 7: | /** |
| 8: | * Runtime registry of known vocabulary namespaces and their aliases. |
| 9: | * |
| 10: | * This interface serves a single purpose at runtime: resolving alias- |
| 11: | * qualified term names to their fully qualified form so that |
| 12: | * AnnotatableInterface::getAnnotation() can accept both forms |
| 13: | * transparently. |
| 14: | * |
| 15: | * The registry is populated once at application boot from the static |
| 16: | * catalog. It has no knowledge of Term definitions, type shapes, or |
| 17: | * generator concerns — those belong to VocabularyCatalogInterface. |
| 18: | * |
| 19: | * Example: |
| 20: | * |
| 21: | * $registry->resolveAlias('UI', 'LineItem'); |
| 22: | * // → "com.sap.vocabularies.UI.v1.LineItem" |
| 23: | * |
| 24: | * $registry->resolveAlias('Core', 'Description'); |
| 25: | * // → "Org.OData.Core.V1.Description" |
| 26: | * |
| 27: | * $registry->fullyQualify('UI.LineItem'); |
| 28: | * // → "com.sap.vocabularies.UI.v1.LineItem" |
| 29: | * |
| 30: | * $registry->fullyQualify('com.sap.vocabularies.UI.v1.LineItem'); |
| 31: | * // → "com.sap.vocabularies.UI.v1.LineItem" (identity, already qualified) |
| 32: | */ |
| 33: | interface VocabularyRegistryInterface |
| 34: | { |
| 35: | /** |
| 36: | * Resolves an alias and a simple term name to the fully qualified |
| 37: | * term name. |
| 38: | * |
| 39: | * Returns null when the alias is unknown to this registry. Does not |
| 40: | * validate whether the term actually exists in the vocabulary — |
| 41: | * that is the generator's concern. |
| 42: | */ |
| 43: | public function resolveAlias(string $alias, string $termName): ?string; |
| 44: | |
| 45: | /** |
| 46: | * Takes a term name that is either alias-qualified ("UI.LineItem") |
| 47: | * or already fully qualified ("com.sap.vocabularies.UI.v1.LineItem") |
| 48: | * and returns the fully qualified form. |
| 49: | * |
| 50: | * Returns null when the input contains an alias that is unknown to |
| 51: | * this registry. Returns the input unchanged when it is already |
| 52: | * fully qualified. |
| 53: | */ |
| 54: | public function fullyQualify(string $term): ?string; |
| 55: | |
| 56: | /** |
| 57: | * Returns all registered alias-to-namespace mappings. |
| 58: | * |
| 59: | * The key is the alias (e.g. "UI"), the value is the full namespace |
| 60: | * (e.g. "com.sap.vocabularies.UI.v1"). Useful for serialising |
| 61: | * Reference and Include elements in a metadata document. |
| 62: | * |
| 63: | * @return array<string, string> |
| 64: | */ |
| 65: | public function getAliasMap(): array; |
| 66: | |
| 67: | /** |
| 68: | * Whether this registry knows the given alias. |
| 69: | */ |
| 70: | public function hasAlias(string $alias): bool; |
| 71: | } |