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

nextras / orm / 28897357009

07 Jul 2026 08:43PM UTC coverage: 92.123% (-0.04%) from 92.166%
28897357009

Pull #796

github

web-flow
Merge cb86ce19a into 556ac76b8
Pull Request #796: add Extension extensibility entry point

44 of 50 new or added lines in 8 files covered. (88.0%)

4339 of 4710 relevant lines covered (92.12%)

5.41 hits per line

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

78.95
/src/Model/SimpleModelFactory.php
1
<?php declare(strict_types = 1);
2

3
namespace Nextras\Orm\Model;
4

5

6
use Nette\Caching\Cache;
7
use Nextras\Orm\Entity\IEntity;
8
use Nextras\Orm\Entity\Reflection\IMetadataParserFactory;
9
use Nextras\Orm\Entity\Reflection\MetadataParserFactory;
10
use Nextras\Orm\Extension;
11
use Nextras\Orm\Repository\IRepository;
12
use function array_values;
13

14

15
class SimpleModelFactory
16
{
17
        /**
18
         * @template E of IEntity
19
         * @param array<string, IRepository<E>> $repositories Map of a repository name and its instance. The name is used
20
         * for accessing repository by name in contrast to accessing by class-string.
21
         * @param list<Extension> $extensions
22
         */
23
        public function __construct(
5✔
24
                private readonly Cache $cache,
1✔
25
                private readonly array $repositories,
1✔
26
                private readonly IMetadataParserFactory|null $metadataParserFactory = null,
1✔
27
                private readonly array $extensions = [],
1✔
28
        )
29
        {
30
        }
6✔
31

32

33
        public function create(): Model
34
        {
35
                $config = Model::getConfiguration($this->repositories);
6✔
36
                $parser = $this->metadataParserFactory ?? new MetadataParserFactory($this->extensions);
6✔
37
                $loader = new SimpleRepositoryLoader(array_values($this->repositories));
6✔
38
                $metadata = new MetadataStorage($config[2], $this->cache, $parser, $loader);
6✔
39
                $model = new Model($config, $loader, $metadata);
6✔
40

41
                foreach ($this->repositories as $repository) {
6✔
42
                        $repository->setModel($model);
6✔
43
                }
44

45
                foreach ($this->extensions as $extension) {
6✔
NEW
46
                        $extension->configureModel($model);
×
NEW
47
                        foreach ($this->repositories as $repository) {
×
NEW
48
                                $extension->configureRepository($repository);
×
NEW
49
                                $extension->configureMapper($repository->getMapper());
×
50
                        }
51
                }
52

53
                return $model;
6✔
54
        }
55
}
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