• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

68publishers / event-dispatcher-extra / 15322966619

29 May 2025 11:35AM UTC coverage: 83.824%. First build
15322966619

Pull #1

github

web-flow
Merge f84369011 into 858a38b40
Pull Request #1: PHP 8.4 support + checks

57 of 68 new or added lines in 4 files covered. (83.82%)

57 of 68 relevant lines covered (83.82%)

0.84 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.89
/src/Bridge/Nette/DI/EventDispatcherExtraExtension.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace SixtyEightPublishers\EventDispatcherExtra\Bridge\Nette\DI;
6

7
use Nette\DI\CompilerExtension;
8
use Nette\DI\Definitions\Definition;
9
use Nette\DI\Definitions\FactoryDefinition;
10
use Nette\DI\Definitions\ServiceDefinition;
11
use Nette\DI\Definitions\Statement;
12
use SixtyEightPublishers\EventDispatcherExtra\EventDispatcherAwareInterface;
13
use SixtyEightPublishers\EventDispatcherExtra\EventDispatcherFactory;
14
use SixtyEightPublishers\EventDispatcherExtra\EventDispatcherFactoryInterface;
15
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
16

17
final class EventDispatcherExtraExtension extends CompilerExtension
18
{
19
    public function loadConfiguration(): void
20
    {
21
        $builder = $this->getContainerBuilder();
1✔
22

23
        $builder->addDefinition($this->prefix('event_dispatcher_factory'))
1✔
24
            ->setType(EventDispatcherFactoryInterface::class)
1✔
25
            ->setFactory(EventDispatcherFactory::class);
1✔
26
    }
1✔
27

28
    public function beforeCompile(): void
29
    {
30
        $builder = $this->getContainerBuilder();
1✔
31

32
        # service existence check
33
        $builder->getByType(EventDispatcherInterface::class, true);
1✔
34

35
        $definitions = array_filter($builder->getDefinitions(), static function (Definition $def): bool {
1✔
36
            return is_a((string) $def->getType(), EventDispatcherAwareInterface::class, true) || ($def instanceof FactoryDefinition && is_a((string) $def->getResultType(), EventDispatcherAwareInterface::class, true));
1✔
37
        });
1✔
38

39
        foreach ($definitions as $definition) {
1✔
40
            if ($definition instanceof FactoryDefinition) {
1✔
NEW
41
                $definition = $definition->getResultDefinition();
×
42
            }
43

44
            if (!($definition instanceof ServiceDefinition)) {
1✔
NEW
45
                continue;
×
46
            }
47

48
            $definition->addSetup('setEventDispatcher', [
1✔
49
                new Statement([$this->prefix('@event_dispatcher_factory'), 'create']),
1✔
50
            ]);
51
        }
52
    }
1✔
53
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc