@@ -107,19 +107,117 @@ protected function execute(InputInterface $input, OutputInterface $output)
107
107
$ this ->trans ('commands.debug.plugin.table-headers.definition-key ' ),
108
108
$ this ->trans ('commands.debug.plugin.table-headers.definition-value ' )
109
109
];
110
+
111
+ $ tableRows = $ this ->prepareTableRows ($ definition );
112
+
113
+ ksort ($ tableRows );
114
+ $ this ->getIo ()->table ($ tableHeader , array_values ($ tableRows ));
115
+
116
+ $ this ->displayPluginData ($ pluginType , $ pluginId );
117
+ return true ;
118
+ }
119
+
120
+ /**
121
+ * Displays additional plugin data.
122
+ *
123
+ * @param string $pluginType
124
+ * Plugin type.
125
+ * @param $pluginId
126
+ * Plugin ID.
127
+ */
128
+ protected function displayPluginData ($ pluginType , $ pluginId ) {
129
+ switch ($ pluginType ) {
130
+ case 'field.field_type ' :
131
+ $ this ->getFieldTypeData ($ pluginId );
132
+ break ;
133
+
134
+ case 'field.formatter ' :
135
+ $ this ->getFieldFormatterData ($ pluginId );
136
+ break ;
137
+
138
+ case 'field.widget ' :
139
+ $ this ->getFieldWidgetData ($ pluginId );
140
+ break ;
141
+ }
142
+ }
143
+
144
+ /**
145
+ * Get field type plugin additional data.
146
+ *
147
+ * @param string $pluginId
148
+ * Plugin ID.
149
+ */
150
+ protected function getFieldTypeData ($ pluginId ) {
151
+ $ settings = $ this ->container ->get ('plugin.manager.field.field_type ' )->getDefaultFieldSettings ($ pluginId );
152
+ $ this ->displaySettingsTable ($ settings );
153
+ }
154
+
155
+ /**
156
+ * Get field formatter plugin additional data.
157
+ *
158
+ * @param string $pluginId
159
+ * Plugin ID.
160
+ */
161
+ protected function getFieldFormatterData ($ pluginId ) {
162
+ $ settings = $ this ->container ->get ('plugin.manager.field.formatter ' )->getDefaultSettings ($ pluginId );
163
+ $ this ->displaySettingsTable ($ settings );
164
+ }
165
+
166
+ /**
167
+ * Get field widget plugin additional data.
168
+ *
169
+ * @param string $pluginId
170
+ * Plugin ID.
171
+ */
172
+ protected function getFieldWidgetData ($ pluginId ) {
173
+ $ settings = $ this ->container ->get ('plugin.manager.field.widget ' )->getDefaultSettings ($ pluginId );
174
+ $ this ->displaySettingsTable ($ settings );
175
+ }
176
+
177
+ /**
178
+ * Displays settings table.
179
+ *
180
+ * @param array $settings
181
+ * Settings array.
182
+ */
183
+ protected function displaySettingsTable ($ settings ) {
184
+ $ tableHeader = [
185
+ $ this ->trans ('commands.debug.plugin.table-headers.setting ' ),
186
+ $ this ->trans ('commands.debug.plugin.table-headers.definition-value ' )
187
+ ];
188
+
189
+ $ tableRows = $ this ->prepareTableRows ($ settings );
190
+
191
+ if (count ($ tableRows ) > 0 ) {
192
+ $ this ->getIo ()->newLine (1 );
193
+ $ this ->getIo ()->info (
194
+ $ this ->trans ('commands.debug.plugin.messages.plugin-info ' )
195
+ );
196
+ $ this ->getIo ()->table ($ tableHeader , array_values ($ tableRows ));
197
+ }
198
+ }
199
+
200
+ /**
201
+ * Prepare table rows.
202
+ *
203
+ * @param array $items
204
+ * Data array.
205
+ *
206
+ * @return array
207
+ * Table rows.
208
+ */
209
+ protected function prepareTableRows ($ items ) {
110
210
$ tableRows = [];
111
- foreach ($ definition as $ key => $ value ) {
211
+ foreach ($ items as $ key => $ value ) {
112
212
if (is_object ($ value ) && method_exists ($ value , '__toString ' )) {
113
213
$ value = (string ) $ value ;
114
214
} elseif (is_array ($ value ) || is_object ($ value )) {
115
215
$ value = Yaml::dump ($ value );
116
216
} elseif (is_bool ($ value )) {
117
217
$ value = ($ value ) ? 'TRUE ' : 'FALSE ' ;
118
218
}
119
- $ tableRows [$ key ] = [$ key , $ value ];
219
+ $ tableRows [] = [$ key , $ value ];
120
220
}
121
- ksort ($ tableRows );
122
- $ this ->getIo ()->table ($ tableHeader , array_values ($ tableRows ));
123
- return true ;
221
+ return $ tableRows ;
124
222
}
125
223
}
0 commit comments