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

nextras / orm / 29191903500

12 Jul 2026 12:02PM UTC coverage: 91.963% (-0.2%) from 92.123%
29191903500

Pull #820

github

web-flow
Merge 8dab47905 into fc483811c
Pull Request #820: refactor OrmExtension for NetteDI (BC break!)

135 of 158 new or added lines in 8 files covered. (85.44%)

1 existing line in 1 file now uncovered.

4348 of 4728 relevant lines covered (91.96%)

5.39 hits per line

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

93.75
/src/Bridges/NetteDI/DiRepositoryLoader.php
1
<?php declare(strict_types = 1);
2

3
namespace Nextras\Orm\Bridges\NetteDI;
4

5

6
use Nette\DI\Container;
7
use Nextras\Orm\Entity\IEntity;
8
use Nextras\Orm\Model\IRepositoryLoader;
9
use Nextras\Orm\Repository\IRepository;
10

11

12
/**
13
 * Loads repositories from Nette DI Container.
14
 * It is {@see OrmExtension} responsibility to register all needed relevant repositories to the Nette DI.
15
 */
16
class DiRepositoryLoader implements IRepositoryLoader
17
{
18
        /**
19
         * @param array<class-string<IRepository<IEntity>>, string> $repositoryClassNameToDiNameMap
20
         * @param array<string, string> $repositoryNameToDiNameMap
21
         * @param array<class-string<IEntity>, class-string<IRepository<*>>> $entityClassNameToRepositoryClassNameMap
22
         */
23
        public function __construct(
5✔
24
                private readonly Container $container,
1✔
25
                private readonly array $repositoryClassNameToDiNameMap,
1✔
26
                private readonly array $repositoryNameToDiNameMap,
1✔
27
                private readonly array $entityClassNameToRepositoryClassNameMap,
1✔
28
        )
29
        {
30
        }
6✔
31

32

33
        #[\Override]
34
        public function hasRepository(string $className): bool
35
        {
36
                return isset($this->repositoryClassNameToDiNameMap[$className]);
6✔
37
        }
38

39

40
        #[\Override]
41
        public function hasRepositoryByName(string $name): bool
42
        {
NEW
43
                return isset($this->repositoryNameToDiNameMap[$name]);
×
44
        }
45

46

47
        #[\Override]
48
        public function getRepository(string $className): IRepository|null
49
        {
50
                return $this->container->getService($this->repositoryClassNameToDiNameMap[$className]);
6✔
51
        }
52

53

54
        #[\Override]
55
        public function getRepositoryByName(string $name): IRepository|null
56
        {
57
                return $this->container->getService($this->repositoryNameToDiNameMap[$name]);
6✔
58
        }
59

60

61
        /**
62
         * @template E of IEntity
63
         * @param class-string<E> $entityClassName
64
         * @return class-string<IRepository<E>>|null
65
         */
66
        #[\Override]
67
        public function getRepositoryClassNameForEntity(string $entityClassName): string|null
68
        {
69
                /** @var class-string<IRepository<E>>|null */
70
                return $this->entityClassNameToRepositoryClassNameMap[$entityClassName] ?? null;
6✔
71
        }
72

73

74
        #[\Override]
75
        public function getInitializedRepositories(): array
76
        {
77
                $repositories = [];
6✔
78
                foreach ($this->repositoryClassNameToDiNameMap as $diName) {
6✔
79
                        if ($this->container->isCreated($diName)) {
6✔
80
                                $repositories[] = $this->container->getService($diName);
6✔
81
                        }
82
                }
83
                return $repositories;
6✔
84
        }
85
}
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