Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Add API documentation to the Explode process plugin.
Comment | File | Size | Author |
---|---|---|---|
#25 | interdiff-18-25.txt | 1.83 KB | jofitz |
#25 | 2845478-25.patch | 1.86 KB | jofitz |
#18 | interdiff.txt | 790 bytes | quietone |
#18 | 2845478-18.patch | 1.81 KB | quietone |
#16 | interdiff.txt | 1.55 KB | quietone |
Comments
Comment #2
quietone CreditAttribution: quietone as a volunteer commentedComment #3
phenaproximaSelf-assigning for review.
Comment #5
phenaproximas/source value/input value
Can this simply say "This plugin splits a string into an array of strings by a delimiter", or similar?
It's not clear how to use this plugin to transform theme_bartik_settings to bartik.settings. I think this example should be clarified.
Should end with a colon.
Should say "the input string".
These lines exceed 80 characters.
String explosion uses a delimiter. It's not clear, therefore, why the delimiter could be optional. We should explain this better.
I don't think we need to mention this. It's the most exotic edge case imaginable.
Comment #6
phenaproximaThis should all be @inheritdoc.
Comment #7
gerzenstl CreditAttribution: gerzenstl at 42mate commentedComment #8
gerzenstl CreditAttribution: gerzenstl at 42mate commentedComment #9
gerzenstl CreditAttribution: gerzenstl at 42mate commentedComment #10
gerzenstl CreditAttribution: gerzenstl at 42mate commentedAdded interdiff.
Comment #11
gerzenstl CreditAttribution: gerzenstl at 42mate commentedAfter I talked with @phenaproxima, I added some changes on the initial explanation.
Also I removed the "(optional)" for the delimiter parameter. It's mandatory, otherwise, it throws an exception on line #63.
Comment #12
phenaproximaLooking better and better. I'd still like to see a more solid example, but we can leave that for a Migrate maintainer.
One nitpick beyond that:
This line exceeds 80 characters.
Comment #13
gerzenstl CreditAttribution: gerzenstl at 42mate commentedFixed line.
Comment #14
John Cook CreditAttribution: John Cook commentedAll looks good :)
Although I would suggest moving line 42 ("If limit is > PHP_INT_MAX it will be set to PHP_INT_MAX.") into the available configuration keys block. This would put this information along with the other options/limits of the 'limit' key and would put the example configuration next to its equivalent PHP code.
Leaving as "Needs review" as other people may disagree with me.
Comment #15
ultimikeI'm not a big fan of this example use case. I often encounter migrations where a source field contains a comma-separated values list of term names or list item values. These need to be exploded to an array to be migrated.
I agree with @phenaproxima's earlier comment - this is such an edge case it can probably be eliminated.
As an aside, I'd **really** like to see an additional parameter (boolean) that allows the user to specify if each array value should be trimmed. If I wrote a patch for this, any chance it would be accepted?
Comment #16
quietone CreditAttribution: quietone as a volunteer commentedReworked the examples and deleted the reference to PHP_INT_MAX.
And made a new issue for the idea about adding a parameter to explode for trimming the results. #2849802: Add option to trim results to explode process plugin.
Comment #17
phenaproximaOne small thing. Other than that, this is good to go.
It would actually be
$bar = explode('/', $foo, 1).
Comment #18
quietone CreditAttribution: quietone as a volunteer commentedYep, a copy/paste error. Also added periods to those sentences.
Comment #19
phenaproximaLooks perfect.
Comment #20
xjmStraightforward code documentation improvements can always go into any patch release, alpha, beta, or RC, so please always file them against the production branch (currently 8.3.x). Thanks!
Comment #22
giorgio79 CreditAttribution: giorgio79 commentedIt might be better to avoid calling this process plugin with the same name of a php function...
Comment #23
John Cook CreditAttribution: John Cook commentedSetting back to RTBC from testbot error.
@giorgio79, it's fine for a plugin to have the same name as a PHP function. The plugin name is just a label and the internals work through a class. As can be seen from the new documentation, it works it has the same effect as the function so the name does not cause confusion.
Comment #24
xjmThis one is very close!
@John Cook is correct; plugin machine names and PHP functions don't need to be unique from each other. Also, note that this is a documentation issue, so discussing the naming that already exists is out of scope for this patch.
Same note as elsewhere about list indentation; the top level needs to have the hyphens at the same indentation as the paragraph above. Believe it or not, this is a coding standard and core has been patched before only to fix such list indentation.
As on the other issue, let's put full lines of PHP (that are actual code rather than just a variable name) in their own
@code
with complete syntax.Thanks!
Comment #25
jofitz CreditAttribution: jofitz at ComputerMinds commentedCorrections in response to code review.
Comment #26
phenaproximaI think the "of" is indented one space too far...? Fixable on commit.
Ditto with "returned".
Comment #29
xjmIndeed, #26 fixed on commit. The diff:
There is now #2852163: Lists in comments not validated to add a rule that should help catch this whitespace issue in the future.
Committed to 8.4.x and cherry-picked to 8.3.x. Thanks everyone!