You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 line
717B

  1. <?php
  2. namespace Framework\Support;
  3. use Framework\App;
  4. abstract class DriverProvider
  5. {
  6. public function bind(App $app): void
  7. {
  8. $name = $this->name();
  9. $factory = $this->factory();
  10. $drivers = $this->drivers();
  11. $app->bind($name, function ($app) use ($name, $factory, $drivers) {
  12. foreach ($drivers as $key => $value) {
  13. $factory->addDriver($key, $value);
  14. }
  15. $config = config($name);
  16. return $factory->connect($config[$config['default']]);
  17. });
  18. }
  19. abstract protected function name(): string;
  20. abstract protected function factory(): DriverFactory;
  21. abstract protected function drivers(): array;
  22. }

Powered by TurnKey Linux.