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 the docs for the line item type definition (http://www.drupalcommerce.org/specification/info-hooks/line-item) states this:
base - string used as the base for the magically constructed callback names, each of which will be defaulted to [base]_[callback] unless explicitly set; defaults to the type
But it doesn't seem to be implemented, I'm attaching a patch for this one.
Comments
Comment #1
pcambraComment #2
pcambraRepo: git.drupal.org:sandbox/pcambra/1081200.git
Branch: 1112900
Diff: http://drupalcode.org/sandbox/pcambra/1081200.git/commitdiff/d3b8d8b5da5...
Comment #3
rszrama CreditAttribution: rszrama commentedIt's used in initialization when the line item types are loaded, so the patch should be unnecessary. Was this not working for you somewhere?
See commerce_line_item_types():
Comment #4
pcambraIf you enable a module that has a custom line item type defined, I think it goes through hook_modules_enabled and in line item module this function has this code:
There's no call to commerce_line_item_types there so the base and callback are not merged. Maybe we could do an array_merge of $line_item_types and commerce_line_item_types() before calling the configure in the hook.
Comment #5
pcambraBack to active
Comment #6
rszrama CreditAttribution: rszrama commentedAhh, indeed, that's a problem. : )
I think perhaps instead we should reset the line item type cache, use commerce_line_item_types() to retrieve the array, and then use the configuration callback from there. By clearing the cache and rebuilding the line item types, we give other modules an appropriate opportunity to alter the configuration callback if required before the configuration actually happens.
Comment #7
pcambraSomething like this?
http://drupalcode.org/sandbox/pcambra/1081200.git/commitdiff/f0793c5d751...
Then we're rebuilding all line items whenever a module is enabled.
Comment #8
rszrama CreditAttribution: rszrama commentedNot quite like that. We still only want to configure the newly enabled line item type, we just want to do the reset so the callbacks array for that particular line item type is populated and altered if necessary.
Comment #9
pcambraAnother try:
http://drupalcode.org/sandbox/pcambra/1081200.git/commitdiff/e643138362f...
Comment #10
rszrama CreditAttribution: rszrama commentedCloser. : ) I just committed a patch that takes it the next step and just doesn't bother with the merge... I just invoke the hook to find out the types to load and configure directly.
Commit: http://drupalcode.org/project/commerce.git/blobdiff/2b021129aee0a49bcb53...