@@ -140,63 +140,17 @@ protected function execute(InputInterface $input, OutputInterface $output): int
140140
141141 if ($ classDefinitionId ) {
142142 $ updateAll = false ;
143-
144- try {
145- $ classDefinition = ClassDefinition::getById ($ classDefinitionId );
146- if (!$ classDefinition ) {
147- throw new IdNotFoundException (
148- sprintf ('ClassDefinition with id %s not found ' , $ classDefinitionId )
149- );
150- }
151-
152- $ this ->output ->writeln (
153- sprintf (
154- '<info>Update index and indices for ClassDefinition with id %s</info> ' ,
155- $ classDefinitionId
156- ),
157- OutputInterface::VERBOSITY_NORMAL
158- );
159-
160- $ this
161- ->indexUpdateService
162- ->updateClassDefinition ($ classDefinition );
163- } catch (Exception $ e ) {
164- $ this ->output ->writeln ('<error> ' . $ e ->getMessage () . '</error> ' );
165- }
143+ $ this ->updateClassDefinition ($ classDefinitionId );
166144 }
167145
168146 if ($ input ->getOption (self ::OPTION_UPDATE_ASSET_INDEX )) {
169147 $ updateAll = false ;
170-
171- try {
172- $ output ->writeln (
173- '<info>Update asset index</info> ' ,
174- OutputInterface::VERBOSITY_NORMAL
175- );
176-
177- $ this
178- ->indexUpdateService
179- ->updateAssets ();
180- } catch (Exception $ e ) {
181- $ this ->output ->writeln ($ e ->getMessage ());
182- }
148+ $ this ->updateAssets ();
183149 }
184150
185151 if ($ input ->getOption (self ::OPTION_UPDATE_DOCUMENT_INDEX )) {
186152 $ updateAll = false ;
187-
188- try {
189- $ output ->writeln (
190- '<info>Update document index</info> ' ,
191- OutputInterface::VERBOSITY_NORMAL
192- );
193-
194- $ this
195- ->indexUpdateService
196- ->updateDocuments ();
197- } catch (Exception $ e ) {
198- $ this ->output ->writeln ($ e ->getMessage ());
199- }
153+ $ this ->updateDocuments ();
200154 }
201155
202156 if ($ updateAll ) {
@@ -229,6 +183,62 @@ protected function execute(InputInterface $input, OutputInterface $output): int
229183 return self ::SUCCESS ;
230184 }
231185
186+ private function updateClassDefinition (string $ classDefinitionId )
187+ {
188+ try {
189+ $ classDefinition = ClassDefinition::getById ($ classDefinitionId );
190+ if (!$ classDefinition ) {
191+ throw new IdNotFoundException (
192+ sprintf ('ClassDefinition with id %s not found ' , $ classDefinitionId )
193+ );
194+ }
195+
196+ $ this ->output ->writeln (
197+ sprintf (
198+ '<info>Update index and indices for ClassDefinition with id %s</info> ' ,
199+ $ classDefinitionId
200+ ),
201+ OutputInterface::VERBOSITY_NORMAL
202+ );
203+
204+ $ this
205+ ->indexUpdateService
206+ ->updateClassDefinition ($ classDefinition );
207+ } catch (Exception $ e ) {
208+ $ this ->output ->writeln ('<error> ' . $ e ->getMessage () . '</error> ' );
209+ }
210+ }
211+
212+ private function updateAssets () : void {
213+ try {
214+ $ this ->output ->writeln (
215+ '<info>Update asset index</info> ' ,
216+ OutputInterface::VERBOSITY_NORMAL
217+ );
218+
219+ $ this
220+ ->indexUpdateService
221+ ->updateAssets ();
222+ } catch (Exception $ e ) {
223+ $ this ->output ->writeln ($ e ->getMessage ());
224+ }
225+ }
226+
227+ private function updateDocuments () : void {
228+ try {
229+ $ this ->output ->writeln (
230+ '<info>Update document index</info> ' ,
231+ OutputInterface::VERBOSITY_NORMAL
232+ );
233+
234+ $ this
235+ ->indexUpdateService
236+ ->updateDocuments ();
237+ } catch (Exception $ e ) {
238+ $ this ->output ->writeln ($ e ->getMessage ());
239+ }
240+ }
241+
232242 private function updateGlobalIndexAliases (): void
233243 {
234244 $ this ->output ->writeln (
0 commit comments