Questions tagged [interface-injection]

Interface injection is an implementation of dependency injection.

Interface injection is an implementation of dependency injection.

An instance of a class implementing an Aware Interface is given additional parameters (or dependencies).

5 questions
4
votes
1 answer

Difference between Interface Injection and Method Injection

I have just started learning about Dependency Injection (DI) and its types in C#. I noticed that in almost all articles, the first two types of injection mechanisms mentioned are same, i.e., Constructor Injection and Property/Setter Injection. But…
Abhishek Guha
  • 154
  • 1
  • 9
1
vote
2 answers

Using interface injection while having to create instances of the underlying object

I have an interface to represent a data structure with competing implementations. I need to use this in a class while decoupling the class from having to know the underlying data structure. And within this class, I will need to create several…
user592748
  • 1,194
  • 3
  • 21
  • 45
1
vote
1 answer

Interface injection with Silex

I'm trying to implement interface injection with Silex\Application. I have my bootstrapping in one PHP file, mind, this is simplified without the interfaces actually: $app = new Silex\Application(); $app->register( new…
Daniel W.
  • 31,164
  • 13
  • 93
  • 151
0
votes
1 answer

Pass interface as the arguent to some function

I want to know. I found this in Symfony2 TranslationLoader class: public function addLoader($format, LoaderInterface $loader) { $this->loaders[$format] = $loader; } I found LoaderInterface there is only one method. But how we know the…
nowiko
  • 2,507
  • 6
  • 38
  • 82
-1
votes
1 answer

Can't pass in interface to controller without throwing error

I created a service class 'TeacherService' with an interface that I want to pass it into my controller's constructor, but when I try there is an error in one of the constructors As soon as I type a comma into the constructors parameters it red…
chuckd
  • 13,460
  • 29
  • 152
  • 331