@@ -76,13 +76,6 @@ public function setValue($value): void
7676 parent ::setValue ($ value );
7777 }
7878
79- public function getValue ()
80- {
81- $ this ->initiateItems ();
82-
83- return \array_key_exists ($ this ->value , $ this ->items ) ? $ this ->value : null ;
84- }
85-
8679 public function signalReceived (string $ signal ): void
8780 {
8881 $ presenter = $ this ->lookup (Presenter::class);
@@ -101,14 +94,19 @@ public function signalReceived(string $signal): void
10194 }
10295 }
10396
97+ /**
98+ * @param string $query
99+ * @param array|int|null $default
100+ * @return array
101+ */
104102 private function getData (string $ query = '' , $ default = null ): array
105103 {
106104 if ($ this ->callback === null ) {
107105 throw new \Nette \InvalidStateException ('Callback for " ' . $ this ->getHtmlId () . '" is not set. ' );
108106 }
109107
110108 if ($ this ->storage instanceof \Nette \Caching \Cache) {
111- $ cacheKey = $ this ->getHtmlId () . '_ ' . $ query . '_ ' . $ default ;
109+ $ cacheKey = $ this ->getHtmlId () . '_ ' . $ query . '_ ' . \is_array ( $ default ) ? \implode ( ' , ' , $ default ) : $ default ;
112110 $ result = $ this ->storage ->load ($ cacheKey );
113111
114112 if (\is_array ($ result ) && !empty ($ result )) {
@@ -131,11 +129,12 @@ private function getData(string $query = '', $default = null): array
131129
132130 private function initiateItems ($ value = null ): void
133131 {
134- if (\count ($ this ->items ) > 0 ) {
132+ if ($ value === null && \count ($ this ->items ) > 0 ) {
135133 return ;
136134 }
137135
138136 if (!\in_array ($ value ?? $ this ->value , [null , '' , []], true )) {
137+ bdump ('here ' );
139138 $ this ->items = $ this ->getData ('' , $ value ?? $ this ->value );
140139 } else {
141140 $ this ->items = $ this ->getData ();
0 commit comments