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.
In EntityListController we have:
public function buildHeader() {
$row['label'] = t('Label');
$row['operations'] = t('Operations');
return $row;
}
but in VocabularyListController we have:
/**
* {@inheritdoc}
*/
public function buildHeader() {
$header['label'] = t('Vocabulary name');
$header['weight'] = t('Weight');
return $header + parent::buildHeader();
}
Using a different variable name makes it harder to follow the method inheritance, and also means that it's harder to move code up and down between inherited methods.
I would suggest $header is better than $row as it's more expressive.
Comment | File | Size | Author |
---|---|---|---|
#10 | 2084257-standardize_variables-10.patch | 835 bytes | beowulf1416 |
#3 | 2084257-standardize_variable-7842374.patch | 591 bytes | beowulf1416 |
Comments
Comment #1
littledynamo CreditAttribution: littledynamo commentedCode sprint planned next week, this task looks ideal for new contributors.
Comment #2
littledynamo CreditAttribution: littledynamo commentedComment #3
beowulf1416 CreditAttribution: beowulf1416 commentedrenamed variable $row to $header in EntityListController::buildHeader()
Comment #4
littledynamo CreditAttribution: littledynamo commented@beowulf1416 I'd earmarked this issue for our code sprint next week but didnt realise you were already working in it. Maybe assign to yourself so I know to steer clear :)
Comment #5
littledynamo CreditAttribution: littledynamo commentedRemoved CodeSprintDundee tag
Comment #6
littledynamo CreditAttribution: littledynamo commentedUnassigning
Comment #7
littledynamo CreditAttribution: littledynamo commentedComment #8
littledynamo CreditAttribution: littledynamo commentedUrgh, no idea how that happened ...
Comment #9
joachim CreditAttribution: joachim commentedIt might be worth checking the other overrides of that method too: https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!EntityList...
Comment #10
beowulf1416 CreditAttribution: beowulf1416 commentedI did the check of the other overrides (16 as of today).
ViewListController::buildHeader()
is totally different. Didn't touch it.
Comment #11
enhdless CreditAttribution: enhdless commentedPatch works great.
Comment #12
joachim CreditAttribution: joachim commentedComment #13
webchickNice clean-up.
Committed and pushed to 8.x. Thanks!