3
我希望能够使用codeigniter进行控制器注入。有没有更改核心控制器文件的库?CodeIgniter和依赖注入/控制器注入
我的使用将是这样的(伪):
厂文件//声明将发生
if (Controller == "Navigation") {
new Navigation(new PageRepository());
}
else{
new Navigation();
}
导航控制文件中的所有依赖
class Navigation extends MX_Controller {
private $repository;
public function __Construct(IPageRepository $repo)
{
parent::__Construct();
$this->repository = $repo;
}
public function index()
{
$data[ "model" ] = $this->repository->GetAllPages();
$this->load->view('index', $data);
}
}
任何人都有任何其他方式依赖注入的线索?我想实现它来进行单元测试!