helper.php 695 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. declare(strict_types=1);
  3. use SixShop\System\ExtensionManager;
  4. if (!function_exists('extension_config')) {
  5. /**
  6. * 获取模块配置
  7. */
  8. function extension_config(string $moduleName, string $key = '', bool $onlyValue = true): mixed
  9. {
  10. return app(ExtensionManager::class)->getExtensionConfig($moduleName, $key, $onlyValue);
  11. }
  12. }
  13. if (!function_exists('array_to_map')) {
  14. function array_to_map(array|null $array, string $key, string $value): array
  15. {
  16. if (empty($array)) {
  17. return [];
  18. }
  19. $map = [];
  20. foreach ($array as $item) {
  21. $map[$item[$key]] = $item[$value];
  22. }
  23. return $map;
  24. }
  25. }