Have an issue with dependency injection in PHP that I can't seem to find the answer to. Ok, quick PHP class:
<?php
namespace myapp;
use myapp\template;
use myapp\order;
class user {
private $template;
public function __construct(template $template) {
$this->template = $template;
}
public function add_order(order $order) {
// do something with $order here
}
}
I'm using the php-di package from http://php-di.org/ although am open to change. My question is, how do I inject directly into that add_order() function? Construct injection is simple, and for example:
$container = new Di\Container();
$container->make(mapp\user);
I want the same type of injection to occur, but while calling the add_order() function directly. I want something like this:
$container = new Di\Container();
$container->make(myapp\user::add_order);
Any help? Thanks~