Several functions in the ingredient.module file can be converted to services:

These three should probably go in the same service:

  • ingredient_quantity_from_decimal()
  • ingredient_greatest_common_divisor()
  • ingredient_quantity_from_fraction()

We don't currently use ingredient_unit_fuzzymatch(), but its functionality is really useful for anyone attempting to do recipe imports. So I want to leave it in the module as a service.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dcam created an issue. See original summary.

nitesh624’s picture

Assigned: Unassigned » nitesh624
nitesh624’s picture

FileSize
23.47 KB
nitesh624’s picture

FileSize
23.47 KB
nitesh624’s picture

FileSize
23.51 KB
nitesh624’s picture

Assigned: nitesh624 » Unassigned
Status: Active » Needs review
nitesh624’s picture

FileSize
23.94 KB
2.08 KB

Fix coding standard warning in last patch

dcam’s picture

FileSize
24.48 KB
2.96 KB

Thank you @nitesh624! I'm sorry that I didn't get to this patch sooner. The last few months have been rough for me. I made a few minor changes, mostly just re-adding the old functions and deprecating them rather than removing them entirely.

dcam’s picture

FileSize
24.48 KB
+++ b/modules/ingredient/ingredient.module
@@ -239,67 +128,12 @@ function ingredient_quantity_from_fraction($ingredient_quantity) {
+  return \Drupal::service('ingredient.quantity')->getUnitFuzzymatch($subject);

I wrote the wrong service here.

  • dcam committed 7639ab1 on 8.x-2.x
    Issue #3156825 by nitesh624, dcam: Convert ingredient.module functions...
dcam’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.