Problem/Motivation
Follow-up to #2899553: Architectural review of the Workflows module (documentation cleanups).
In \Drupal\workflows\Form\WorkflowAddForm::form
$workflow_types = array_map(function ($plugin_definition) {
return $plugin_definition['label'];
}, $this->workflowTypePluginManager->getDefinitions());
could just use array_column.
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | 2902018-18.patch | 752 bytes | vijaycs85 |
Comments
Comment #2
timmillwoodComment #3
meenakshig commentedchanged array_map to array_column. please let me know is it correct ?
Comment #4
meenakshig commentedsorry my previous patch arraycolumn_2902018_1.patch was not correct i have changed array_map to array_column only in one place so here i have changed it where ever possible
Comment #5
amateescu commented@Meenakshi Gupta, the array_column() function is not a direct replacement for array_map(), they do entirely different things :) I linked each of them to their documentation on php.net so you can see exactly how they should be used.
Comment #6
amateescu commentedMaybe the issue title was confusing...
Comment #7
meenakshig commented@amateescu thanks for clarifying :)
Comment #8
meenakshig commentedComment #9
harsha012 commentedDo we need to change all the array_map() to array_column() in the workflow module ?
i have fixed the array_column() syntax in WorkflowAddForm.php
Comment #10
timmillwoodNot all array_map() functions make sense to move to array_column(), but if they do I say lets change them.
These should be on the same line.
Comment #11
harsha012 commentedfixed as per #10
Comment #12
timmillwoodI don't think we can change the calls to
\Drupal\workflows\State::labelCallback, this doesn't return "label", it returns the label of a state.Please provide an interdiff with patches. https://www.drupal.org/documentation/git/interdiff
Comment #14
harsha012 commentedinterdiff
Comment #16
vijaycs85I don't think it makes sense to update any place other than addForm and current patch needs a change to make machinename/id as key:
Comment #17
sam152 commentedYup, none of these can use array_column because they are a method call on an object, not accessing an array value.
@vijaycs85 is also correct, the third param should be 'id' to be used as the array key.
Comment #18
vijaycs85Thanks for confirming @Sam152. Here is a patch.
Comment #19
sam152 commentedLooks good to me.
Comment #20
larowlanCrediting @Sam152, @timmillwood and @amateescu for reviews and mentoring.
Comment #23
larowlanCommitted as 4210adf and pushed to 8.5.x.
Cherry-picked as 73fd8e2 and pushed to 8.4.x.