ConfigProvider.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of Hyperf.
  5. *
  6. * @link https://www.hyperf.io
  7. * @document https://hyperf.wiki
  8. * @contact group@hyperf.io
  9. * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
  10. */
  11. namespace Hyperf\Devtool;
  12. use Hyperf\Database\Commands\CommandCollector;
  13. class ConfigProvider
  14. {
  15. public function __invoke()
  16. {
  17. return [
  18. 'annotations' => [
  19. 'scan' => [
  20. 'paths' => [
  21. __DIR__,
  22. ],
  23. ],
  24. ],
  25. 'commands' => [
  26. ...$this->getDatabaseCommands(),
  27. ],
  28. 'publish' => [
  29. [
  30. 'id' => 'config',
  31. 'description' => 'The config for devtool.',
  32. 'source' => __DIR__ . '/../publish/devtool.php',
  33. 'destination' => BASE_PATH . '/config/autoload/devtool.php',
  34. ],
  35. ],
  36. ];
  37. }
  38. private function getDatabaseCommands(): array
  39. {
  40. if (! class_exists(CommandCollector::class)) {
  41. return [];
  42. }
  43. return CommandCollector::getAllCommands();
  44. }
  45. }