. * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU Affero General Public License version 3. * * In accordance with Section 7(b) of the GNU Affero General Public License version 3, * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ namespace Espo\Tools\OpenApi\Util; use Espo\Core\Utils\Metadata; use Espo\ORM\Defs\FieldDefs; class EnumOptionsProvider { public function __construct( private Metadata $metadata, ) {} /** * @return ?string[] */ public function get(FieldDefs $fieldDefs): ?array { /** @var ?string $path */ $path = $fieldDefs->getParam('optionsPath'); /** @var ?string $path */ $ref = $fieldDefs->getParam('optionsReference'); if (!$path && $ref && str_contains($ref, '.')) { [$refEntityType, $refField] = explode('.', $ref); $path = "entityDefs.$refEntityType.fields.$refField.options"; } /** @var ?string[] $optionList */ $optionList = $path ? $this->metadata->get($path) : $fieldDefs->getParam('options'); return $optionList; } }