EventServiceProvider.php 651 B

1234567891011121314151617181920212223242526
  1. <?php
  2. declare(strict_types=1);
  3. namespace Yansongda\Pay\Service;
  4. use Symfony\Component\EventDispatcher\EventDispatcher;
  5. use Yansongda\Pay\Contract\EventDispatcherInterface;
  6. use Yansongda\Pay\Contract\ServiceProviderInterface;
  7. use Yansongda\Pay\Exception\ContainerException;
  8. use Yansongda\Pay\Pay;
  9. class EventServiceProvider implements ServiceProviderInterface
  10. {
  11. /**
  12. * @param mixed $data
  13. *
  14. * @throws ContainerException
  15. */
  16. public function register($data = null): void
  17. {
  18. if (class_exists(EventDispatcher::class)) {
  19. Pay::set(EventDispatcherInterface::class, new EventDispatcher());
  20. }
  21. }
  22. }