このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン 次のリビジョン 両方とも次のリビジョン | ||
slim:4:routing [2020/10/10 17:50] y2sunlight [コンテナ―ソリユーション] |
slim:4:routing [2020/10/10 20:57] y2sunlight [コントローラーをコンテナーに登録する] |
||
---|---|---|---|
行 491: | 行 491: | ||
- | ==== Registering a controller with the container | + | ==== コントローラーをコンテナーに登録する |
- | Create a controller with the '' | + | '' |
- | + | ||
- | '' | + | |
<code php> | <code php> | ||
行 523: | 行 521: | ||
} | } | ||
</ | </ | ||
- | |||
- | Create a factory in the container that instantiates the controller with the dependencies: | ||
依存関係を持つコントローラーをインスタンス化するファクトリをコンテナーに作成します。 | 依存関係を持つコントローラーをインスタンス化するファクトリをコンテナーに作成します。 | ||
行 541: | 行 537: | ||
}); | }); | ||
</ | </ | ||
- | |||
- | This allows you to leverage the container for dependency injection and so you can inject specific dependencies into the controller. | ||
これにより、依存関係の注入にコンテナーを活用できるため、特定の依存関係をコントローラーに注入できます。 | これにより、依存関係の注入にコンテナーを活用できるため、特定の依存関係をコントローラーに注入できます。 |