コンテナの導入

[Foo]
sample = Bar_Sample

とかiniファイルに書いておくと、アクションクラスの中でクラスBar_Sampleのインスタンスをコンテナ経由で取得できるようにする。

クラス名がBar_Sampleの場合、以下の順番でクラスファイルを探索する(include_pathを考慮)。

  • Bar/Sample.php
  • Bar/Sample.class.php
class Foo extends Moony_Action
{
    function execute($t)
    {
        $container = $this->getContainer('/path/to/ini_file');
        $sample = $container->get('sample');
    }
}