@@ -230,30 +230,30 @@ public function getConversionDefinition(string $name): ?MediaConversionDefinitio
230230 return $ value ;
231231 }
232232
233- public function dispatchConversion (string $ conversion ): ?PendingDispatch
233+ /**
234+ * @return array<string, MediaConversionDefinition>
235+ */
236+ public function getChildrenConversionsDefinitions (string $ name ): array
234237 {
238+ return $ this ->getConversionDefinition ($ name )?->conversions ?? [];
239+ }
235240
236- $ definition = $ this -> getConversionDefinition ( $ conversion );
237-
238- if (! $ definition ) {
239- return null ;
241+ public function dispatchConversion ( string $ conversion ): ? PendingDispatch
242+ {
243+ if ($ definition = $ this -> getConversionDefinition ( $ conversion ) ) {
244+ return $ definition -> dispatch ( $ this , $ this -> getParentConversion ( $ conversion )) ;
240245 }
241246
242- return $ definition ->dispatch ($ this , $ this ->getParentConversion ($ conversion ));
243-
247+ return null ;
244248 }
245249
246250 public function executeConversion (string $ conversion ): ?MediaConversion
247251 {
248-
249- $ definition = $ this ->getConversionDefinition ($ conversion );
250-
251- if (! $ definition ) {
252- return null ;
252+ if ($ definition = $ this ->getConversionDefinition ($ conversion )) {
253+ return $ definition ->execute ($ this , $ this ->getParentConversion ($ conversion ));
253254 }
254255
255- return $ definition ->execute ($ this , $ this ->getParentConversion ($ conversion ));
256-
256+ return null ;
257257 }
258258
259259 public function getConversion (string $ name ): ?MediaConversion
@@ -321,7 +321,7 @@ public function addConversion(
321321 if ($ existingConversion ) {
322322 $ existingConversion ->deleteFile ();
323323 $ this ->deleteChildrenConversion ($ conversionName );
324- } elseif ( $ this -> relationLoaded ( ' conversions ' )) {
324+ } else {
325325 $ this ->conversions ->push ($ conversion );
326326 }
327327
@@ -339,7 +339,7 @@ public function dispatchConversions(
339339 ?MediaConversion $ parent = null
340340 ): static {
341341 if ($ parent ) {
342- $ definitions = $ this ->getConversionDefinition ($ parent ->conversion_name )?->conversions ?? [] ;
342+ $ definitions = $ this ->getChildrenConversionsDefinitions ($ parent ->conversion_name );
343343 } else {
344344 $ definitions = $ this ->getConversionsDefinitions ();
345345 }
@@ -426,7 +426,8 @@ public function makeFreshPath(
426426 ?string $ conversion = null ,
427427 ?string $ fileName = null
428428 ): string {
429- $ prefix = config ()->string ('media.generated_path_prefix ' , '' );
429+ /** @var string $prefix */
430+ $ prefix = config ('media.generated_path_prefix ' ) ?? '' ;
430431
431432 $ root = Str::of ($ prefix )
432433 ->when ($ prefix , fn ($ string ) => $ string ->finish ('/ ' ))
0 commit comments