What are the Slack Archives?
It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.
Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..
}Hello, I am having trouble with dependency injection through the 'injector/' directory in the modu
}Hello,
I am having trouble with dependency injection through the 'injector/' directory in the module. I saw in the documentation that you can inject dependency this way but it is not working for me. Can someone please guide me if this way works for you? I am trying to inject a dependency in CheckoutPageDepedencyProvider
Here is my code ...
config_default.php:
// ---------- Dependency injector $config[KernelConstants::DEPENDENCY_INJECTOR_YVES] = [ 'CheckoutPage' => [ PaymentMethodsConstants::PROVIDER_NAME, ], ];
MyProject\Yves\PaymentMethods\Dependency\Injector\PaymentDependencyProvider.php
<?php namespace MyProject\Yves\PaymentMethods\Dependency\Injector; use Spryker\Yves\DummyPayment\Dependency\Injector\CheckoutDependencyInjector; use Spryker\Yves\Kernel\Container; use MyProject\Yves\PaymentMethods\Plugin\DirectDebitSubFormPlugin; use Spryker\Yves\Checkout\CheckoutDependencyProvider; use Spryker\Yves\StepEngine\Dependency\Plugin\Form\SubFormPluginCollection; use Spryker\Yves\Kernel\Dependency\Injector\DependencyInjectorInterface; class CheckoutPageDependencyInjector implements DependencyInjectorInterface { /** * @param \Spryker\Yves\Kernel\Container $container * * @return \Spryker\Yves\Kernel\Container */ protected function injectPaymentSubForms(Container $container): Container { $container->extend( CheckoutDependencyProvider::PAYMENT_SUB_FORMS, function (SubFormPluginCollection $paymentSubForms) { $paymentSubForms->add(new DirectDebitSubFormPlugin()); return $paymentSubForms; }); return $container; } public function inject(Container $container): Container { $container = $this->injectPaymentSubForms($container); return $container; } }
Comments
-
Hi, what is the value of
PaymentMethodsConstants::PROVIDER_NAME
? I believe it should bePaymentMethods
0 -
@U019WGU7SM9 Yes it is
PaymentMethods
0 -
Well that looks ok to me then - a couple of more things you could check
1. clear your resolver cache:vendor/bin/console cache:class-resolver:build
2. I’m not sure whether you have to extend the AbstractDependencyInjector, but might be worth trying
3. I assume you’ve already been working with code in theMyProject
namespace, but if you haven’t, then it’ll need to be added to$config[KernelConstants::PROJECT_NAMESPACES]
0 -
@U019WGU7SM9 Thanks. The namespace is added in the project namespaces. All other files work just not this one. I am going to try your 2nd point now.
0 -
I miss
use Spryker\Yves\Kernel\Dependency\Injector\DependencyInjectorInterface;
in your injector class0 -
@UNGMX0012 forgot to add it in the message, I do have it in the code. Updated.
0 -
@UNGMX0012 @U019WGU7SM9 looks like the config settings in
config_oms-development.php
are overiding the settings inconfig_default.php
0 -
aha
0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 78 Spryker News
- 936 Developer Corner
- 793 Spryker Development
- 90 Spryker Dev Environment
- 362 Spryker Releases
- 3 Oryx frontend framework
- 35 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 27 Job Opportunities
- 3.2K 📜 Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 33 Product & Business Questions
- 69 Spryker Safari Questions
- 50 Random