File tree 1 file changed +32
-1
lines changed
1 file changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,9 @@ abstract class BaseItemList extends BaseHtmlElement
33
33
34
34
protected $ tag = 'ul ' ;
35
35
36
+ /** @var ?string Message when the list is empty */
37
+ protected $ emptyStateMessage ;
38
+
36
39
/**
37
40
* Create a new item list
38
41
*
@@ -76,6 +79,34 @@ protected function createListItem(object $data)
76
79
return new $ className ($ data , $ this );
77
80
}
78
81
82
+ /**
83
+ * Get message to show for empty list
84
+ *
85
+ * @return string
86
+ */
87
+ public function getEmptyStateMessage (): string
88
+ {
89
+ if ($ this ->emptyStateMessage === null ) {
90
+ return t ('No items found. ' );
91
+ }
92
+
93
+ return $ this ->emptyStateMessage ;
94
+ }
95
+
96
+ /**
97
+ * Set message for empty list
98
+ *
99
+ * @param string $message
100
+ *
101
+ * @return $this
102
+ */
103
+ public function setEmptyStateMessage (string $ message ): self
104
+ {
105
+ $ this ->emptyStateMessage = $ message ;
106
+
107
+ return $ this ;
108
+ }
109
+
79
110
protected function assemble (): void
80
111
{
81
112
foreach ($ this ->data as $ data ) {
@@ -87,7 +118,7 @@ protected function assemble(): void
87
118
88
119
if ($ this ->isEmpty ()) {
89
120
$ this ->setTag ('div ' );
90
- $ this ->addHtml (new EmptyStateBar (t ( ' No items found. ' )));
121
+ $ this ->addHtml (new EmptyStateBar ($ this -> getEmptyStateMessage ( )));
91
122
}
92
123
}
93
124
}
You can’t perform that action at this time.
0 commit comments