+ addDiscoverRow($data, $title, $chunkGames);
+ $title = '';
+ }
+
+ return $data;
+}
+
+/**
+ * Modify a category to make it suitable for the Razer Forge TV
+ *
+ * - Fold rows without title into the previous row
+ * - Remove automatically generated categories ("Last updated", "Best rated")
+ *
+ * @see buildDiscoverCategory()
+ */
+function convertCategoryToForge($data, $removeAutoCategories = false)
+{
+ //merge tiles from rows without title into the previous row
+ $lastTitleRowId = null;
+ foreach ($data['rows'] as $rowId => $row) {
+ if ($row['title'] !== '') {
+ $lastTitleRowId = $rowId;
+ } else if ($lastTitleRowId !== null) {
+ $data['rows'][$lastTitleRowId]['tiles'] = array_merge(
+ $data['rows'][$lastTitleRowId]['tiles'],
+ $row['tiles']
+ );
+ unset($data['rows'][$rowId]);
+ }