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 function _services_build_resources we have two drupal_alter's that do completely the same:
drupal_alter('services_resources', $resources, $endpoint);
and about 20 lines below
drupal_alter('services_resources_post_processing', $resources, $endpoint);
As we don't change resources between these two calls I can't see reason to keep both hooks. Lets decide which one is not needed.
Comment | File | Size | Author |
---|---|---|---|
#9 | 0001-Comment-about-deprecated-hook_services_resources_pos.patch | 1.1 KB | ygerasimov |
#7 | 0001-Comment-abou-deprecated-hook_services_resources_post.patch | 986 bytes | ygerasimov |
Comments
Comment #1
marcingy CreditAttribution: marcingy commentedResources are altered in this code block as $resource is passed by reference.
So I don't think anything needs to change here are the resource can change between the 2 alter calls.
Comment #2
ygerasimov CreditAttribution: ygerasimov commented@marcingy yes, I agree that we pass it by reference, but in function _services_process_resource we only add 'name' property to each of $resources. So not much things added at all.
Can we think about use case of both hooks? Or when we should use one or the other?
Comment #3
marcingy CreditAttribution: marcingy commentedThe first alter allows me to amend resources before the controller get populated as the values in resource affects what the controller element looks like so it makes it simplier to manipulate.
eg
In the first alter I can simply unset $resource['actions'] in the second I can achieve the same thing but I also have to manipulate the controller array. This is ineffect an api change so it couldn't go into this version as we are now at RC and trying to get a release out so it has to be postpond.
Comment #4
ygerasimov CreditAttribution: ygerasimov commentedAlright. Lets postpone this issue.
But @marcingy can you update documentation about these hooks? Specially difference between them.
Comment #5
marcingy CreditAttribution: marcingy commentedMy point is that someone could be using either hook therefore we can not remove them as it is an api - I personally can't provide docs re when to use one or the other because the answer is that either of them could be used for the same thing we are simple to far the rc process to rationalise them.
Comment #6
marcingy CreditAttribution: marcingy commentedMay the answer for now is mark one as deprecated, so as it warns people it is going to be removed.
Comment #7
ygerasimov CreditAttribution: ygerasimov commentedAlright. Lets mark hook_services_resources_post_processing_alter as deprecated as the other one is used by rest server.
Comment #8
marcingy CreditAttribution: marcingy commentedI'd get rid of this part of the comment otherwise it is good (called about 20 lines up).
Comment #9
ygerasimov CreditAttribution: ygerasimov commentedHere is updated patch.
Comment #10
marcingy CreditAttribution: marcingy commentedComment #15
marcingy CreditAttribution: marcingy commentedCommitted to d6 and d7