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.
From http://drupal.org/node/1497230#comment-5826480 we should establish a standard for function calls that pull "global" information (currently in global variables but soon from the drupal_container()) to be at the start of a given function so that we can improve readability.
Creating this a separate issue so that #1497230: Use Dependency Injection to handle object definitions can move forward.
Comments
Comment #1
Crell CreditAttribution: Crell commentedShouldn't we standardize on not using globals in the first place and leveraging dependency injection properly? :-) This seems like an unnecessary step.
Comment #2
pdrake CreditAttribution: pdrake commentedFor OO code, leveraging dependency injection is probably sufficient, but for code which remains firmly procedural (of which I imagine there will be some in D8), the dependencies have to be explicitly instantiated or made available within scope of the function, correct?
Comment #3
cosmicdreams CreditAttribution: cosmicdreams commented@Crell, yes, the key of this issue is not the manner in which the information is passed to the function, just a standardization of where the information is passed from a outside of the class (when arguments are not used) to the inner scoping of a function.
I couldn't think of a better title and this issue only has a "title fail". If anyone has a proper description of the issue please rename it.
Comment #4
catchI actually prefer the $GLOBALS syntax since it's more clear in context where the value is coming from - for example it makes it much more difficult to confuse global $user and $account and similar.
Also this is so not a wscci issue.
Comment #5
sunComment #6
sunComment #7
wizonesolutionsGonna try taking a stab at this.
Comment #8
wizonesolutionsIsn't $GLOBALS the PHP way to do it (when absolutely necessary)?
Comment #9
jhodgdonThis issue is not ready for a patch yet. We first need to discuss and establish the standard.
Comment #10
jhodgdonCoding standards decisions are now supposed to be made by the TWG... and I don't think this is relevant to dependency injection any more?
Comment #11
Crell CreditAttribution: Crell commentedI think this is in practice irrelevant now, per #1.
Comment #12
jhodgdonOK, let's just close this.