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.
Updated: Comment #N
Problem/Motivation
If we want to move drupal_render into a class at some point, we need the utility functions it uses to also be in their own class. This will also make the code much easier to test.
Proposed resolution
Move element_property, element_properties, element_child, element_children, element_get_visible_children, and element_set_attribute into a standalone Element class.
Remaining tasks
User interface changes
None
API changes
Deprecate methods above? leaving in wrappers.
Related Issues
Comment | File | Size | Author |
---|---|---|---|
#18 | drupal-core-convert-element-functions-2109793-18.patch | 3.56 KB | InternetDevels |
#11 | element-2109793.patch | 22.44 KB | dawehner |
#11 | interdiff.txt | 3.54 KB | dawehner |
Comments
Comment #1
damiankloip CreditAttribution: damiankloip commentedI have literally run out of time, so I'm just posting how far I got. Unit test is incomplete, plus comments for function in common.inc need work.
Comment #3
dawehnerI personally think that it is not time to convert the render api to OOP as just having static methods all over the place is hard.
We should rather avoid to call drupal_render() as much as possible and if we do wrap it in some methods without logic. Given that a missing
test coverage is okay.
Comment #4
damiankloip CreditAttribution: damiankloip commentedI still think this is a good idea, and better than what we have now, often we will want this before the render stage, like form API, see new methods like FormBuilder::elementChildren() for a good example..
This should fix tests and add some more coverage.
Comment #5
dawehnerLet's add @deprecated to all of them
Can we update the logs?
nice!!
Comment #6
damiankloip CreditAttribution: damiankloip commentedGreat, thanks for the review. Here we go.
Sorry, two inderdiffs. Pure laziness, to not recreate it as one :)
Comment #7
dawehnerThank you
Comment #8
Xano6: 2109793-6.patch queued for re-testing.
Comment #9
Xano6: 2109793-6.patch queued for re-testing.
Comment #10
tim.plunkettLet's finish the test coverage and reap the benefits...
Comment #11
dawehnerIs it just me that we are testing things here which actually better belong into a unit test?
Comment #12
damiankloip CreditAttribution: damiankloip commentedYep, that is indeed all unit tested now!
RTBC for those changes on top of the original RTBC.
Comment #13
damiankloip CreditAttribution: damiankloip commentedComment #14
webchickCommitted and pushed to 8.x. Thanks!
This'll need a change notice.
Comment #15
tstoecklerThis patch contained a minor API change in that you can now no longer pass strings or objects into element_properties(). Before they were cast to an array, and now Element::properties() type-hints array for the $element parameter. Not disagreeing with the change or anything, but that should be mentioned on the change notice.
Comment #16
sunLet's create a follow-up issue to remove the @deprecated functions entirely.
Comment #17
dawehnerHere is a quick one: [#2173683]
Comment #18
InternetDevels CreditAttribution: InternetDevels commentedWas this issue created? I just checked common.inc and found that there are still several places where element_children used. I've created a patch for this but not sure where post it.
Comment #19
dawehner@InternetDevels
Please use #2181507: Remove the deprecated usages of element_* methods for fixing it.
Comment #20
dermarioHi i just applied that patch (before testbot was ready) and it worked fine for me.
There is one thing i found:
In children method there is element_children() mentioned in a comment:
Maybe that needs to be fixed too?
Comment #21
Les LimI cleaned up dawehner's quick change notice in https://drupal.org/node/2173683 and assigned it to the Drupal core change list.
Re: tstoeckler's point in #15, I wrote up a separate change notice about that API difference and referenced the original change notice within: https://drupal.org/node/2182161
Marking this as fixed; there's a separate issue for removing the deprecated function calls at #2181507: Remove the deprecated usages of element_* methods.
Comment #22
star-szrNice, thanks @Les Lim :) Just reverting title and priority.