Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
responsive_image.module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
28 Jun 2013 at 14:43 UTC
Updated:
29 Jul 2014 at 22:35 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
rainbowarrayIf this is something that's still needed, maybe we should check with [attiks] on what's needed to make these changes?
Comment #2
jeroentAdded getters and setters for the pictureMapping entity.
Comment #3
johnennew commentedHi @jeroen12345
Some initial comments on your patch
1. There is no need for a getId() or getUuid() methods - id() and uuid() is provided by the Entity class.
2. These methods need to be declared in the appropriate interface first (i.e. core/modules/picture/lib/Drupal/picture/PictureMappingInterface.php)
3. The Infodoc comments will be placed in the interface, comment standards require a short description, followed by parameter declarations followed by return values. i.e...
Note, I've not looked at the behaviour of the module so don't know what should be returned in this case.
5. Coding standards - the opening brace should be on the same line as the function declaration. i.e. ...
6. Setters need to return the $this object to allow chaining of functions. There is also a specific convention around the setting of values (see some of the other issues in this meta issue for details).
Comment #4
mike.davis commentedComment #5
mike.davis commentedHere is an updated patch following on from ceng's comments
Comment #6
dawehnerSo this code calls getBreakpointGroup() multiple times, ... why not just use if ($breakpoint_group = $this->getBreakpointGroup()) {
Let's use {@inheritdoc}
These methods need to to document the return value as well as have a online description.
These methods need a one-line description.
We could save a call to getBreakpointGroup as well.
Just a general question ... is there a reason why we have small and thumbnail (I know this is out of scope).
Comment #7
mike.davis commentedI've made changes from previous comments so here is a new slightly modified patch.
Comment #8
xanoLooks good! I've got a few comments, mostly about the documentation standards:
If a method returns the object it was called on, we document this with
@return self. This needs to be changed multiple times.We use EntityInterface::label() for this.
The array's keys and values need to be documented as well.
Just mappings.
The parameter type indicates a class, but its description talks about an array. Which one is it? If it's a class, the type must be namespaced.
The class name of the return value needs to be namespaced in the docblock. This needs to be changed multiple times.
Comment #9
mike.davis commentedThanks for your comments @Xano. I have been working on this recently so hope to have a patch soon.
Comment #10
star-szrUnassigning and tagging so folks can work on the doc updates mentioned in #8.
@mike.davis if you are still working on this please feel free to reassign.
Comment #11
mike.davis commentedThanks @Cottser, I am still working on this - been a bit delayed with the holidays and working through issues that have come up after an update :).
Comment #12
mike.davis commentedTypical, spent ages scratching my head about a silly merge issue. OK I have finally managed to get an updated patch for this now :)
Comment #13
rainbowarrayJust a note that it looks like this patch still applies if somebody more knowledgeable than me wants to review it.
Comment #14
rainbowarrayHiding older patches.
Comment #15
xanoI updated some documentation and type hints. Someone with more knowledge of the internals than me must document the mapping array structure for
\Drupal\picture\PictureMappingInterface::setMappings(),\Drupal\picture\PictureMappingInterface::getMappings(), and probably for\Drupal\picture\Entity\PictureMapping::mappingsas well.Comment #16
xanoComment #17
attiks commentedFYI: picture is renamed to responsive_image so this needs a reroll once #2124377-74: Rename "Picture" module to "Responsive Image" module is committed
Comment #18
eli-tNote there is a problem in that getMappings() and setBreakpointGroup() are inconsistent in what they return.
getMappings() can return an array in the format
or
Similarly, getBreakpointGroup can either be a string specifying the breakpoint group, or an object of class \Drupal\breakpoint\Entity\BreakpointGroup.
These problems weren't caused by this issue, although I believe the added @return value in the docblock for \Drupal\breakpoint\Entity\BreakpointGroup::getBreakpointGroup() is wrong whilst the method is inconsistent in return type. However, the issue will be easier to fix once this patch is implemented.
Comment #19
JayeshSolanki commentedComment #20
alexpottThanks @Eli-T for talking about #18 and open an issue to address this #2219329: ResponsiveImageMapping::mappings and ResponsiveImageMapping::breakpointGroup properties have inconsistent return structure and type respectively - it's super awkward atm.
Comment #21
JayeshSolanki commentedReroll the patch #15 as picture module has been changed to responsive _image module
Comment #23
JayeshSolanki commentedComment #24
JayeshSolanki commentedComment #25
JayeshSolanki commentedComment #26
eli-tComment #27
JayeshSolanki commentedComment #28
JayeshSolanki commentedComment #29
attiks commentedLooks good to me, once this is committed we can address the remarks from #18
Comment #30
alexpottIf we are going to add setters and getters can we make the mappings and breakpointGroup properties protected? This will necessitate changing all the code that accesses the public properties but this is a good thing.
Comment #31
eli-tComment #32
eli-tAlso needs changes following #2219925: Rename ConfigEntityInterface::getExportProperties() to toArray()
Comment #33
eli-tProtected $mappings and $breakpointGroup, and renamed getExportProperties() to toArray().
Comment #34
mcjim commentedPatch in #33 looks good to go. Address the issues raised in #30. Tests pass.
Comment #36
eli-tFix unit test fail in ResponsiveImageMappingEntityTest::testCalculateDependencies().
Note there are leftover references to Picture module in the unit tests that should have been picked up under #2124377: Rename "Picture" module to "Responsive Image" module but I don't intend fixing those under this issue.
Comment #37
rainbowarrayThere isn't a picture module more, so we can't put in a patch that refers to the picture module. The tests need to be modified to refer to the responsive image module.
Comment #38
eli-t#2225677: Fix naming in ResponsiveImageMappingEntityTest following module rename from Picture to Responsive Image has been raised to fix the naming issues in the unit tests. These do not prevent the tests from being run and weren't caused by this issue.
Comment #39
eli-tComment #40
rainbowarrayFair enough!
Comment #41
mcjim commented… and fix in #36 means it passes unit tests, too!
Comment #42
alexpottCommitted ed5d055 and pushed to 8.x. Thanks!
Can existing change notices be checked.
Comment #44
marcvangendSorry for arriving here after the commit, but...
Assuming that getBreakpointById() returns a single breakpoint, as the docs in BreakpointGroupInterface say, why is the variable called $breakpointGroup? And if it is a group, shouldn't the variable be called
$breakpoint_group?Comment #45
eli-tComment #46
eli-tPatch to address #44.
No interdiff as previous patch was committed.
Comment #47
eli-tComment #48
marcvangendPatch applies and works as expected.
Comment #50
xano46: expand-responsive_image-mapping-with-methods-2030653-46.patch queued for re-testing.
Comment #51
xanoRTBC, as the tests failed because of a segmentation fault on the server.
Comment #52
alexpottCommitted 2fe3785 and pushed to 8.x. Thanks!
Comment #54
eli-t