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

contributte / datagrid / 8685602316

13 Mar 2024 12:24PM UTC coverage: 34.102%. Remained the same
8685602316

push

github

web-flow
[7.x] Next (#1060)

* PHP 8.0

* Translator: switch from ITranslator to Translator (#973)

* [7.x] Bootstrap 5 + PHP 8 + vanilla javascript (#1021)

* Bootstrap 5

* Bootstrap 5 (docs)

* Bootstrap 5

* form-control -> form-select

* Bump bootstrap-select for Bootstrap 5 support

* Removed `input-sm` from Bootstrap 3

See https://getbootstrap.com/docs/4.0/migration/#forms-1

* Bootstrap 5: When selectpicker, replace form-select classes with form-control and refresh it

* Hide `underline` also for `dropdown-item`. And merged into one CSS rule.

* Update the filterMultiSelect initialization

* Text-align: left -> start

Co-authored-by: Radim Vaculík <radim.vaculik@gmail.com>
Co-authored-by: Jaroslav Líbal <jaroslav.libal@neatous.cz>

* [7.x] phpstan-deprecation-rules (#1061)

* Fix sort

* Add method for setting custom Action href, v6.x (#853)

* [7.x] Nextras ORM 4 support, closes #984

* Fix ElasticsearchDataSource.php data source (#1041)

* Error: Typed property Ublaboo\DataGrid\InlineEdit\InlineEdit::$itemID must not be accessed before initialization

* composer: allow-plugins: php-http/discovery

* ItemDetailForm: $httpPost: Typed property must not be accessed...

* phpstan: revert  --memory-limit=4G

* NetteDatabaseSelectionHelper: Context -> Explorer, getSupplementalDriver -> getDriver

* Update README.md

* Templates: fix variables

* data-bs-toggle attribute for multiaction button (#1072)

* dependabot.yml (#1078)

* Allow nette/utils:4.0 (#1077)

* Add onColumnShow and onColumnHide event methods (#1076)

* Add onColumnShow and onColumnHide event methods

* Add native type array

* Removed duplicity

* Return value of BackedEnum when reading Doctrine entity property. (#1081)

* Return value of BackedEnum when reading array value (#1083)

* Added method to check if filter is on default values; Closes #1082 (#1084)

* ublaboo -> contributte (#1067) (#1075)

* Delete depe... (continued)

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

1455 existing lines in 67 files now uncovered.

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

47.83
/src/Traits/TButtonRenderer.php
1
<?php declare(strict_types = 1);
2

3
namespace Contributte\Datagrid\Traits;
4

5
use Contributte\Datagrid\Column\Renderer;
6
use Contributte\Datagrid\Exception\DatagridColumnRendererException;
7
use Contributte\Datagrid\Exception\DatagridException;
8
use Contributte\Datagrid\Row;
9

10
trait TButtonRenderer
11
{
12

13
        protected ?Renderer $renderer = null;
14

15
        protected array $replacements = [];
16

17
        /**
18
         * @throws DatagridColumnRendererException
19
         */
20
        public function useRenderer(?Row $row = null): mixed
1✔
21
        {
22
                $renderer = $this->getRenderer();
1✔
23

24
                $args = $row instanceof Row ? [$row->getItem()] : [];
1✔
25

26
                if ($renderer === null) {
1✔
27
                        throw new DatagridColumnRendererException();
1✔
28
                }
29

UNCOV
30
                if ($renderer->getConditionCallback() !== null) {
×
UNCOV
31
                        if (call_user_func_array($renderer->getConditionCallback(), $args) === false) {
×
NEW
32
                                throw new DatagridColumnRendererException();
×
33
                        }
34

UNCOV
35
                        return call_user_func_array($renderer->getCallback(), $args);
×
36
                }
37

UNCOV
38
                return call_user_func_array($renderer->getCallback(), $args);
×
39
        }
40

41
        /**
42
         * Set renderer callback and (it may be optional - the condition callback will decide)
43
         *
44
         * @return static
45
         * @throws DatagridException
46
         */
47
        public function setRenderer(
48
                callable $renderer,
49
                ?callable $conditionCallback = null
50
        ): self
51
        {
UNCOV
52
                if ($this->hasReplacements()) {
×
NEW
53
                        throw new DatagridException('Use either Column::setReplacement() or Column::setRenderer, not both.');
×
54
                }
55

UNCOV
56
                $this->renderer = new Renderer($renderer, $conditionCallback);
×
57

UNCOV
58
                return $this;
×
59
        }
60

61
        /**
62
         * @return static
63
         */
64
        public function setRendererOnCondition(
65
                callable $renderer,
66
                callable $conditionCallback
67
        ): self
68
        {
UNCOV
69
                return $this->setRenderer($renderer, $conditionCallback);
×
70
        }
71

72
        public function getRenderer(): ?Renderer
73
        {
74
                return $this->renderer;
1✔
75
        }
76

77
        public function hasReplacements(): bool
78
        {
UNCOV
79
                return $this->replacements !== [];
×
80
        }
81

82
        public function applyReplacements(Row $row, string $column): array
1✔
83
        {
84
                $value = $row->getValue($column);
1✔
85

86
                if ((is_scalar($value) || $value === null) &&
1✔
87
                        isset($this->replacements[gettype($value) === 'double' ? (int) $value : $value])) {
1✔
UNCOV
88
                        return [true, $this->replacements[gettype($value) === 'double' ? (int) $value : $value]];
×
89
                }
90

91
                return [false, null];
1✔
92
        }
93

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