@@ -23,18 +23,24 @@ public function parseValue($value, ?Column $column = null): string {
2323 }
2424
2525 $ intValue = (int )$ value ;
26- if ((string )$ intValue === (string )$ value ) {
27- // if it seems to be an option ID
28- foreach ($ column ->getSelectionOptionsArray () as $ option ) {
29- if ($ option ['id ' ] === $ intValue && $ option ['label ' ] !== $ value ) {
30- return json_encode ($ option ['id ' ]);
31- }
26+ foreach ($ column ->getSelectionOptionsArray () as $ option ) {
27+ if ($ option ['id ' ] === $ intValue ) {
28+ return json_encode ($ option ['id ' ]);
3229 }
33- } else {
34- foreach ($ column ->getSelectionOptionsArray () as $ option ) {
35- if ($ option ['label ' ] === $ value ) {
36- return json_encode ($ option ['id ' ]);
37- }
30+ }
31+
32+ return '' ;
33+ }
34+
35+ public function parseDisplayValue ($ value , ?Column $ column = null ): string {
36+ if (!$ column ) {
37+ $ this ->logger ->warning ('No column given, but expected on ' . __FUNCTION__ . ' within ' . __CLASS__ , ['exception ' => new \Exception ()]);
38+ return '' ;
39+ }
40+
41+ foreach ($ column ->getSelectionOptionsArray () as $ option ) {
42+ if ($ option ['label ' ] === $ value ) {
43+ return json_encode ($ option ['id ' ]);
3844 }
3945 }
4046
@@ -56,22 +62,30 @@ public function canBeParsed($value, ?Column $column = null): bool {
5662 }
5763
5864 $ intValue = (int )$ value ;
59- if ((string )$ intValue === (string )$ value ) {
60- // if it seems to be an option ID
61- foreach ($ column ->getSelectionOptionsArray () as $ option ) {
62- if ($ option ['id ' ] === $ intValue && $ option ['label ' ] !== $ value ) {
63- return true ;
64- }
65- }
66- } else {
67- foreach ($ column ->getSelectionOptionsArray () as $ option ) {
68- if ($ option ['label ' ] === $ value ) {
69- return true ;
70- }
65+ foreach ($ column ->getSelectionOptionsArray () as $ option ) {
66+ if ($ option ['id ' ] === $ intValue ) {
67+ return true ;
7168 }
7269 }
7370
7471 return false ;
7572 }
7673
74+ public function canBeParsedDisplayValue ($ value , ?Column $ column = null ): bool {
75+ if (!$ column ) {
76+ $ this ->logger ->warning ('No column given, but expected on ' . __FUNCTION__ . ' within ' . __CLASS__ , ['exception ' => new \Exception ()]);
77+ return false ;
78+ }
79+ if ($ value === null ) {
80+ return true ;
81+ }
82+
83+ foreach ($ column ->getSelectionOptionsArray () as $ option ) {
84+ if ($ option ['label ' ] === $ value ) {
85+ return true ;
86+ }
87+ }
88+
89+ return false ;
90+ }
7791}
0 commit comments