Fix wrong type for "images" option in ProductFixture#9553
Conversation
pamil
left a comment
There was a problem hiding this comment.
Given that current ProductFixture implementation does not work, I started to wonder about the current configuration structure.
images:
- ['path1.jpg', 'main']
- ['path2.jpg', 'thumbnail']
- ['path3.jpg', 'thumbnail']looks worse to me than alternatives:
images:
'path1.jpg': 'main'
'path2.jpg': 'thumbnail'
'path3.jpg': 'thumbnail'or the best one:
images:
- { path: 'path1.jpg', type: 'main' }
- { path: 'path2.jpg', type: 'thumbnail' }
- { path: 'path3.jpg', type: 'thumbnail' }The last one looks the best for me, so I think we should make it work that way while keeping and deprecating the first way in ProductExampleFactory. WDYT?
|
The best to me would be: images:
main: 'path1.jpg'
thumbnail: 'path2.jpg' |
|
But yeah, it'd be a problem when we want to leave the type empty. So I'll go with your second option. |
|
Yeah, that was my first thought too, but the type is nullable and is not unique. |
0d98bc0 to
d8f064e
Compare
| { | ||
| foreach ($options['images'] as $image) { | ||
| $imagePath = array_shift($image); | ||
| $imagePath = array_key_exists('path', $image) ? $image['path'] : array_shift($image); |
There was a problem hiding this comment.
@pamil Should we actually @trigger_error here?
There was a problem hiding this comment.
👍, if there's no path key in that array.
There was a problem hiding this comment.
But is it okay to add deprecation in a bug fix? 😆
There was a problem hiding this comment.
We could add the deprecation in another PR targeting master, WDYT?
There was a problem hiding this comment.
Ah, that's right indeed! Let's add the deprecation in an another PR.
d8f064e to
8630cbf
Compare
8630cbf to
dd45c48
Compare
|
Thanks, Teoh! 🥇 |
|
Created #9581 for that deprecation addition. |
It wasn't actually working with
ProductExampleFactory, but the tests don't catch it.