-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Backport][2.2] Reworked gallery.phtml to move generation of gallery json strings to own block functions #18443
[Backport][2.2] Reworked gallery.phtml to move generation of gallery json strings to own block functions #18443
Conversation
The 2.3 PR is here #18440. This PR brings 2.2-develop up to the same status as 2.3. It includes rework of the gallery template file and inclusion of more extensive unit testing. |
Hi @sidolov, thank you for the review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @gwharton,
I just compared this PR to original one, it contains little bit another change set.
For instance in file Magento/Catalog/Block/Product/View/Gallery.php
we don't have some cleanups.
Could you add all of your changes to this pr from original one? It would be much easier to review equal changes.
Thank you!
@ihor-sviziev No problems. I'll get those changes made later today. A point of note which I hope you can clarify. I'm not sure where I heard this, but I believed it was recommended to use fully qualified class path names in 2.2, and use the "use" statement and shorthand class path names in 2.3. That was why I did not adjust the class path names in the 2.2 PR, hence the difference in the 2.2 and 2.3 PRs. I've tried searching for this advice again to confirm and cannot find it, and see that 2.3 tends to use the shorthand with "use" clause method for all new code. Should I assume this should be followed for all new code in both 2.2 and 2.3 branches, and under what circumstances class pathnames in existing code should be altered when modifying code? |
Hi @gwharton,
Thank you for raising it! |
I've updated the classnames in 2.2 to use the "use FQCN" formats in Magento/Catalog/Block/Product/View/Gallery.php so the same changes are applied in both branches, although to be honest, I could revert ALL changes to this file in both branches without breaking things (as all required code changes were moved from Gallery.php to GalleryOptions.php, the changes remaining in Gallery.php were mainly cleanup (although it does adjust the json encode function to use framework instead of php functions (totally unrelated to this fix, but good to have changed))). The differences in Magento/Catalog/Test/Unit/Block/Product/View/GalleryTest.php are because these two test file have diverged slightly between 2.2 and 2.3, but the PRs make the necessary changes in both branches, including the "use FQDN" format for class names in both branches. The changes in file dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/GalleryTest.php are only present in 2.2 as this test was removed in 2.3. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's wait for 2.3 PR finalization and then rewrite history in this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gwharton please rewrite branch history similar to original PR.
… own block functions.
@orlangur History squashed and force pushed, as requested. |
Hi @sidolov, thank you for the review. |
✔️ QA passed |
Hi @gwharton, thank you for your contribution! |
…n of gallery json strings to own block functions #18443
Original Pull Request
#18440
Description
Reworked gallery.phtml to move generation of gallery json strings to own block functions
Introduced unit tests to cover generation of gallery json strings with full type checking.
The resultant code is much easier to diagnose and test. It uses the json_encode and json_decode routines instead of the old manual way of generating json strings that were used in the old gallery.phtml which is prone to error and mistakes.
Fixed Issues (if relevant)
Manual testing scenarios
Stock Magento should be
and
All strings/bools/ints are now typed properly as per the Magento dev docs for the Magento 2 Gallery Widget.
Contribution checklist