Error: Call to undefined method Drupal\commerce_payment\PaymentOptionsBuilder::t() in Drupal\commerce_payment\PaymentOptionsBuilder->buildOptions() (line 111 of modules/contrib/commerce/modules/payment/src/PaymentOptionsBuilder.php)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

czigor created an issue. See original summary.

czigor’s picture

Status: Active » Needs review
FileSize
706 bytes
bojanz’s picture

We need to inject $string_translation, and add the missing test coverage.

  • bojanz committed 75b64d5 on 8.x-2.x
    Issue #2958865 by czigor: Call to undefined method Drupal\...
bojanz’s picture

Status: Needs review » Fixed

Done.

agoradesign’s picture

Why do you inject the string translation manager, but use the trait then? (btw, it's recommended to use the trait anyway regarding docs)

bojanz’s picture

Because the trait provides an API not provided by the service:

  protected function t($string, array $args = [], array $options = []) {
    return new TranslatableMarkup($string, $args, $options, $this->getStringTranslation());
  }

  protected function formatPlural($count, $singular, $plural, array $args = [], array $options = []) {
    return new PluralTranslatableMarkup($count, $singular, $plural, $args, $options, $this->getStringTranslation());
  }

It's odd, I know.

agoradesign’s picture

true...wow.. didn't know that

Status: Fixed » Closed (fixed)

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