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

contributte / datagrid / 22805673536

07 Mar 2026 07:28PM UTC coverage: 51.268% (+2.4%) from 48.875%
22805673536

push

github

f3l1x
Add NetteDatabaseDataSource for raw SQL queries via Nette\Database\Explorer

Ports the contributte/datagrid-nette-database-data-source package into
the main datagrid repository. Uses subquery wrapping for filter injection
instead of PHPSQLParser, avoiding any extra dependencies.

128 of 128 new or added lines in 1 file covered. (100.0%)

15 existing lines in 1 file now uncovered.

1516 of 2957 relevant lines covered (51.27%)

0.51 hits per line

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

44.44
/src/Filter/FilterMultiSelect.php
1
<?php declare(strict_types = 1);
2

3
namespace Contributte\Datagrid\Filter;
4

5
use Contributte\Datagrid\Datagrid;
6
use Nette\Application\UI\Form;
7
use Nette\Forms\Container;
8
use Nette\Forms\Controls\BaseControl;
9
use UnexpectedValueException;
10

11
class FilterMultiSelect extends FilterSelect
12
{
13

14
        protected ?string $type = 'multi-select';
15

16
        protected array $attributes = [
17
                'class' => ['form-select', 'form-select-sm', 'selectpicker'],
18
                'data-selected-text-format' => ['count'],
19
        ];
20

21
        public function __construct(
22
                Datagrid $grid,
1✔
23
                string $key,
1✔
24
                string $name,
1✔
25
                array $options,
1✔
26
                string $column
1✔
27
        )
28
        {
29
                parent::__construct($grid, $key, $name, $options, $column);
1✔
30

31
                $this->addAttribute('data-selected-icon-check', Datagrid::$iconPrefix . 'check');
1✔
32
        }
1✔
33

34
        /**
35
         * Get filter condition
36
         */
37
        public function getCondition(): array
38
        {
39
                $return = [$this->column => []];
1✔
40

41
                foreach ($this->getValue() as $value) {
1✔
42
                        $return[$this->column][] = $value;
1✔
43
                }
44

45
                return $return;
1✔
46
        }
47

48
        protected function addControl(
49
                Container $container,
50
                string $key,
51
                string $name,
52
                array $options
53
        ): BaseControl
54
        {
55
                /**
56
                 * Set some translated texts
57
                 */
UNCOV
58
                $form = $container->lookup(Form::class);
×
59

UNCOV
60
                if (!$form instanceof Form) {
×
UNCOV
61
                        throw new UnexpectedValueException();
×
62
                }
63

UNCOV
64
                $translator = $form->getTranslator();
×
65

UNCOV
66
                if ($translator === null) {
×
UNCOV
67
                        throw new UnexpectedValueException();
×
68
                }
69

UNCOV
70
                $this->addAttribute(
×
UNCOV
71
                        'title',
×
UNCOV
72
                        $translator->translate('contributte_datagrid.multiselect_choose')
×
73
                );
UNCOV
74
                $this->addAttribute(
×
UNCOV
75
                        'data-i18n-selected',
×
UNCOV
76
                        $translator->translate('contributte_datagrid.multiselect_selected')
×
77
                );
78

79
                /**
80
                 * Add input to container
81
                 */
UNCOV
82
                $input = $container->addMultiSelect($key, $name, $options);
×
83

UNCOV
84
                $this->addAttributes($input);
×
85

UNCOV
86
                return $input;
×
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