[Maple-user: 211] Re: クラスの中で別のクラスを使うには

Back to archive index

Kamito updoo****@gmail*****
2006年 3月 8日 (水) 11:50:39 JST


こんにちは上戸です。

当初の目的の一つのファイルに複数クラスの宣言ができるかどうかですが,試してみたところ,これ自体は大丈夫みたいですね.
簡単にテストしてみました.

webapp/components/Test.class.php
class Test
{
    function Test(){}
    function getStr()
    {
        $_str = new Str();
        return $_str->str;
    }
}
class Str
{
    var $str = "test";
}

webapp/modules/index/Index.class.php
class Index
{
    var $test = null;
    var $_str = "";
    function Index() {}
    function execute()
    {
        $this->_str = $this->test->getStr();	
        return 'success';
    }
    function getStr()
    {
        return $this->_str;
    }
}

dicon.ini
[DIContainer]
test = component://test
[test]

maple.ini
[DIContainer2]
filename = dicon.ini
[Action]
test = ref:test
[View]
success="index.tpl"

でテンプレートから {action->getStr} でStrの"test"という文字列を取り出せました.
自分はDIContainer2を使っているので上記のような設定になりますが,通常のDIContainerをお使いであれば書式が変わります.
以上ご報告まで.



Maple-user メーリングリストの案内
Back to archive index