@@ -77,24 +77,34 @@ public function run($request)
77
77
78
78
// find all classes we have to index and do so
79
79
foreach ($ algoliaService ->indexes as $ indexName => $ index ) {
80
- echo 'Updating index ' . $ indexName . PHP_EOL ;
80
+ $ environmentizedIndexName = $ algoliaService ->environmentizeIndex ($ indexName );
81
+
82
+ echo 'Updating index ' . $ environmentizedIndexName . PHP_EOL ;
81
83
82
84
$ classes = (isset ($ index ['includeClasses ' ])) ? $ index ['includeClasses ' ] : null ;
83
85
$ indexFilters = (isset ($ index ['includeFilter ' ])) ? $ index ['includeFilter ' ] : [];
84
86
85
87
if ($ classes ) {
86
88
foreach ($ classes as $ candidate ) {
87
89
if ($ targetClass && $ targetClass !== $ candidate ) {
88
- continue ;
90
+ // check to see if target class is a subclass of the candidate
91
+ if (!is_subclass_of ($ targetClass , $ candidate )) {
92
+ continue ;
93
+ } else {
94
+ $ candidate = $ targetClass ;
95
+ }
89
96
}
90
97
91
98
92
99
$ items = $ this ->getItems ($ candidate , $ filter , $ indexFilters );
100
+
101
+ $ filterLabel = implode (', ' , array_filter (array_merge ([$ filter ], [$ indexFilters [$ candidate ] ?? '' ])));
102
+
93
103
echo sprintf (
94
- '| Found %s %s remaining to index which match filter (%s) %s ' ,
104
+ '| Found %s %s remaining to index %s %s ' ,
95
105
$ items ->count (),
96
106
$ candidate ,
97
- implode ( ' , ' , array_merge ([ $ filter ], [ $ indexFilters [ $ candidate ] ?? '' ])) ,
107
+ $ filterLabel ? ' which match filters ' . $ filterLabel : '' ,
98
108
PHP_EOL
99
109
);
100
110
@@ -106,7 +116,7 @@ public function run($request)
106
116
}
107
117
108
118
109
- echo 'Done ' ;
119
+ echo 'Done ' . PHP_EOL ;
110
120
}
111
121
112
122
0 commit comments