Describe your bug or feature request.
------ ----------------------------------------------------------------------
Line modules/price/src/Element/Price.php
------ ----------------------------------------------------------------------
41 \Drupal calls should be avoided in classes, use dependency injection
instead
🪪 globalDrupalDependencyInjection.useDependencyInjection Issue fork commerce-3589151
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
aayushpathak commentedworking..
Comment #4
aayushpathak commentedComment #5
aayushpathak commentedComment #7
jsacksick commentedThe right fix is to use the ContainerFactoryPluginInterface, not ignore the error.
Comment #8
tbkot commentedComment #10
jsacksick commentedThank you, merged!
Comment #12
klausiThis change is not correct:
Error: Call to undefined method Drupal\Core\Render\Element\FormElementBase::create() in Drupal\commerce_price\Element\Price::create() (line 44 of modules/contrib/commerce/modules/price/src/Element/Price.php).
the parent class FormElementBase has no create() method, so we cannot call parent::create().
Unfortunately PHPStan is only set to level 1 in the commerce module, a higher level would have easily detected this mistake. Funny that a phpstan fix issue introduces a bug that would have been caught by phpstan.
@aayushpathak I assume you vibe-coded this change and never tested the code manually? Please don't do that in the future.
I'll try to make a fix, should be only 1 line change.
Comment #14
klausiMR: https://git.drupalcode.org/project/commerce/-/merge_requests/701
Comment #15
jsacksick commented@klausi: A parent create() exists in D11, within
Drupal\Core\Plugin\PluginBase. But it doesn't in D10.I'll merge your MR, thanks for the fix :).
Comment #18
klausiAha, good point about Drupal 11 - I was testing with Drupal 10, sorry for the confusion.