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 );
}
}
他の方法で依存性注入について手がかりを持っている人はいますか? 単体テスト用に実装したい!