1: <?php
2:
3: declare(strict_types=1);
4:
5: namespace LaravelUi5\OData\Edm\Vocabularies;
6:
7: /**
8: * Build-time ordered catalog of all vocabulary sources for the generator.
9: *
10: * Entries are listed in dependency order: every vocabulary appears after
11: * all vocabularies it depends on. The generator processes entries in this
12: * exact order so that cross-vocabulary type references resolve correctly.
13: *
14: * @see VocabularyCatalogInterface
15: */
16: final readonly class VocabularyCatalog implements VocabularyCatalogInterface
17: {
18: /** @param list<VocabularyEntryInterface> $entries */
19: public function __construct(
20: private array $entries,
21: ) {}
22:
23: /**
24: * Returns the canonical default catalog containing all supported
25: * OData and SAP vocabularies in dependency order.
26: */
27: public static function default(): self
28: {
29: return new self([
30: new VocabularyEntry(
31: namespace: 'Org.OData.Core.V1',
32: alias: 'Core',
33: uri: 'https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Core.V1.xml',
34: phpNamespace: 'LaravelUi5\\OData\\Vocabularies\\Core\\V1',
35: dependencies: [],
36: ),
37: new VocabularyEntry(
38: namespace: 'Org.OData.Validation.V1',
39: alias: 'Validation',
40: uri: 'https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Validation.V1.xml',
41: phpNamespace: 'LaravelUi5\\OData\\Vocabularies\\Validation\\V1',
42: dependencies: ['Core'],
43: ),
44: new VocabularyEntry(
45: namespace: 'Org.OData.Measures.V1',
46: alias: 'Measures',
47: uri: 'https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Measures.V1.xml',
48: phpNamespace: 'LaravelUi5\\OData\\Vocabularies\\Measures\\V1',
49: dependencies: ['Core'],
50: ),
51: new VocabularyEntry(
52: namespace: 'Org.OData.Aggregation.V1',
53: alias: 'Aggregation',
54: uri: 'https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Aggregation.V1.xml',
55: phpNamespace: 'LaravelUi5\\OData\\Vocabularies\\Aggregation\\V1',
56: dependencies: ['Core'],
57: ),
58: new VocabularyEntry(
59: namespace: 'Org.OData.Authorization.V1',
60: alias: 'Authorization',
61: uri: 'https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Authorization.V1.xml',
62: phpNamespace: 'LaravelUi5\\OData\\Vocabularies\\Authorization\\V1',
63: dependencies: ['Core'],
64: ),
65: new VocabularyEntry(
66: namespace: 'Org.OData.Capabilities.V1',
67: alias: 'Capabilities',
68: uri: 'https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Capabilities.V1.xml',
69: phpNamespace: 'LaravelUi5\\OData\\Vocabularies\\Capabilities\\V1',
70: dependencies: ['Core', 'Authorization'],
71: ),
72: new VocabularyEntry(
73: namespace: 'com.sap.vocabularies.Common.v1',
74: alias: 'Common',
75: uri: 'https://sap.github.io/odata-vocabularies/vocabularies/Common.xml',
76: phpNamespace: 'LaravelUi5\\OData\\Vocabularies\\Common\\V1',
77: dependencies: ['Core', 'Validation', 'Measures'],
78: ),
79: new VocabularyEntry(
80: namespace: 'com.sap.vocabularies.UI.v1',
81: alias: 'UI',
82: uri: 'https://sap.github.io/odata-vocabularies/vocabularies/UI.xml',
83: phpNamespace: 'LaravelUi5\\OData\\Vocabularies\\Ui\\V1',
84: dependencies: ['Core', 'Common'],
85: ),
86: new VocabularyEntry(
87: namespace: 'com.sap.vocabularies.Analytics.v1',
88: alias: 'Analytics',
89: uri: 'https://sap.github.io/odata-vocabularies/vocabularies/Analytics.xml',
90: phpNamespace: 'LaravelUi5\\OData\\Vocabularies\\Analytics\\V1',
91: dependencies: ['Core', 'Common', 'Aggregation'],
92: ),
93: new VocabularyEntry(
94: namespace: 'com.sap.vocabularies.Communication.v1',
95: alias: 'Communication',
96: uri: 'https://sap.github.io/odata-vocabularies/vocabularies/Communication.xml',
97: phpNamespace: 'LaravelUi5\\OData\\Vocabularies\\Communication\\V1',
98: dependencies: ['Core', 'Common'],
99: ),
100: new VocabularyEntry(
101: namespace: 'com.sap.vocabularies.PersonalData.v1',
102: alias: 'PersonalData',
103: uri: 'https://sap.github.io/odata-vocabularies/vocabularies/PersonalData.xml',
104: phpNamespace: 'LaravelUi5\\OData\\Vocabularies\\PersonalData\\V1',
105: dependencies: ['Core', 'Common'],
106: ),
107: ]);
108: }
109:
110: /** @return list<VocabularyEntryInterface> */
111: public function getEntries(): array
112: {
113: return $this->entries;
114: }
115:
116: public function getEntry(string $namespace): ?VocabularyEntryInterface
117: {
118: foreach ($this->entries as $entry) {
119: if ($entry->getNamespace() === $namespace) {
120: return $entry;
121: }
122: }
123: return null;
124: }
125: }
126: