投稿日時: 2016/11/11
牟田口
こんにちは。
プログラムを担当している牟田口です。
共通コンポーネントのコンストラクタで、他の共通コンポーネントを参照したけどnullのままで使えない問題を対応しました。
--- \webapp\modules\fruit\action\dicon.ini (OKパターン)
ichigoCommonView = "ichigo.view"
remonCommonView = "remon.view"
remonCommonAction = "remon.action"
--- \webapp\modules\fruit\action\dicon.ini (NGパターン)
remonCommonView = "remon.view"
remonCommonAction = "remon.action"
ichigoCommonView = "ichigo.view"
--- \webapp\components\remon\Action.class.php
class Remon_Action {
var $_db = null;
var $_container = null;
var $_request = null;
var $_remonCommonView = null;
var $_ichigoCommonView = null;
/**
* コンストラクター
*
* @accesspublic
*/
function Remon_Action() {
$this->_container =& DIContainerFactory::getContainer();
$this->_db =& $this->_container->getComponent("DbObject");
$this->_request =& $this->_container->getComponent('Request');
$this->_remonCommonView =& $this->_container->getComponent('remonCommonView');
$this->_ichigoCommonView =& $this->_container->getComponent('ichigoCommonView');
var_dump($this->_ichigoCommonView);
// var_dump出力 OKパターン:object(Kyomu_View)
// var_dump出力 NGパターン:null
}
}
NGパターンの場合、ichigoCommonViewのクラス生成前に、remonCommonActionのクラス生成が始まるため、nullのままと推察。
ichigoCommonViewのメソッドを呼び出そうとしたけど、nullのため、下記エラーが発生した。
Fatal error: Call to a member function getXXXX() on a non-object
問題解決の参考になれば幸いです。