EventServiceProvider.php 645 B

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