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

nette / application / 28120116131

24 Jun 2026 05:59PM UTC coverage: 84.766% (+0.2%) from 84.605%
28120116131

push

github

dg
added CLAUDE.md

1992 of 2350 relevant lines covered (84.77%)

0.85 hits per line

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

12.5
/src/Bridges/ApplicationDI/PresenterFactoryCallback.php
1
<?php declare(strict_types=1);
2

3
/**
4
 * This file is part of the Nette Framework (https://nette.org)
5
 * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
6
 */
7

8
namespace Nette\Bridges\ApplicationDI;
9

10
use Nette;
11
use function array_filter, array_values, class_exists, count, implode, touch;
12

13

14
/**
15
 * PresenterFactory callback.
16
 * @internal
17
 */
18
final class PresenterFactoryCallback
19
{
20
        public function __construct(
1✔
21
                private readonly Nette\DI\Container $container,
22
                private readonly ?string $touchToRefresh,
23
        ) {
24
        }
1✔
25

26

27
        /** @param class-string<Nette\Application\IPresenter>  $class */
28
        public function __invoke(string $class): Nette\Application\IPresenter
29
        {
30
                $services = $this->container->findByType($class);
×
31
                if (count($services) > 1) {
×
32
                        $services = array_values(array_filter($services, fn($service) => $this->container->getServiceType($service) === $class));
×
33
                        if (count($services) > 1) {
×
34
                                throw new Nette\Application\InvalidPresenterException("Multiple services of type $class found: " . implode(', ', $services) . '.');
×
35
                        }
36
                }
37

38
                if (count($services) === 1) {
×
39
                        $presenter = $this->container->createService($services[0]);
×
40
                        assert($presenter instanceof Nette\Application\IPresenter);
41
                        return $presenter;
×
42
                }
43

44
                if ($this->touchToRefresh && class_exists($class)) {
×
45
                        touch($this->touchToRefresh);
×
46
                        echo 'Class ' . htmlspecialchars($class) . ' was not found in DI container.<br><br>If you just created this presenter, it should be enough to refresh the page. It will happen automatically in 5 seconds.<br><br>Otherwise, please check the configuration of your DI container.';
×
47
                        header('Refresh: 5');
×
48
                        exit;
×
49
                }
50

51
                throw new Nette\Application\InvalidPresenterException("No services of type $class found.");
×
52
        }
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