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

contributte / datagrid / 8230157862

11 Mar 2024 09:02AM UTC coverage: 34.102%. First build
8230157862

Pull #1060

github

radimvaculik
Fix failing tests
Pull Request #1060: [7.x] Next

117 of 435 new or added lines in 54 files covered. (26.9%)

1124 of 3296 relevant lines covered (34.1%)

0.34 hits per line

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

0.0
/src/Utils/ItemDetailForm.php
1
<?php declare(strict_types = 1);
2

3
namespace Contributte\Datagrid\Utils;
4

5
use Nette\Application\UI\Presenter;
6
use Nette\ComponentModel\IComponent;
7
use Nette\Forms\Container;
8
use Nette\Forms\Form;
9
use Nette\Utils\Arrays;
10
use UnexpectedValueException;
11

12
final class ItemDetailForm extends Container
13
{
14

15
        /** @var callable */
16
        private $callableSetContainer;
17

18
        /** @var ?array */
19
        private ?array $httpPost = null;
20

21
        /** @var array<bool> */
22
        private array $containerSetByName = [];
23

24
        public function __construct(callable $callableSetContainer)
25
        {
26
                $this->monitor(
×
27
                        Presenter::class,
×
NEW
28
                        function (Presenter $presenter): void {
×
29
                                $this->loadHttpData();
30
                        }
×
31
                );
32

33
                $this->callableSetContainer = $callableSetContainer;
×
34
        }
35

36
        public function offsetGet(mixed $name): IComponent
37
        {
38
                return $this->getComponentAndSetContainer($name);
×
39
        }
40

41
        public function getComponentAndSetContainer(mixed $name): IComponent
42
        {
43
                $container = $this->addContainer($name);
×
44

45
                if (!isset($this->containerSetByName[$name])) {
×
46
                        call_user_func($this->callableSetContainer, $container);
×
47

48
                        $this->containerSetByName[$name] = true;
×
49
                }
50

51
                return $container;
×
52
        }
53

54
        /**
55
         * @throws UnexpectedValueException
56
         */
57
        private function getHttpData(): mixed
58
        {
59
                if ($this->httpPost === null) {
×
NEW
60
                        $lookupPath = $this->lookupPath(Form::class);
×
61
                        $form = $this->getForm();
×
62

NEW
63
                        $path = explode(self::NameSeparator, $lookupPath);
×
64

65
                        $this->httpPost = Arrays::get($form->getHttpData(), $path, null);
×
66
                }
67

68
                return $this->httpPost;
×
69
        }
70

71
        /**
72
         * @throws UnexpectedValueException
73
         */
74
        private function loadHttpData(): void
75
        {
76
                $form = $this->getForm();
×
77

78
                if ($form->isSubmitted() === false) {
×
79
                        return;
×
80
                }
81

82
                foreach ((array) $this->getHttpData() as $name => $value) {
×
NEW
83
                        if ((is_iterable($value))) {
×
84
                                $this->getComponentAndSetContainer($name);
×
85
                        }
86
                }
87
        }
88

89
}
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