dicon.iniですが・・・
dicon.iniでのクラスの指定ですが、わかりづらいなと思いまして・・・
(現在)[person:jp.kunit.example1.person] ↓ (提案)[person => jp/kunit/example1/person]
とかどうでしょうかねぇ。
[DIするクラスのエイリアス名(別名?登録名?) => クラスへのパス]
という感じです。セクション名は空白も'='も'>'も大丈夫なようなので、このほうが直感的かな?と思いました。
一応パッチ。
*** maple3.0.0_org/maple/core/DIContainer.class.php Tue Nov 30 22:26:18 2004 --- maple3.0.0_patch/maple/core/DIContainer.class.php Mon Sep 5 22:33:04 2005 *************** *** 118,124 **** **/ function _buildComponents() { foreach ($this->_config as $name => $body) { ! list ($alias, $class) = preg_split("/:/", $name); $this->_attributes[$alias] = array(); --- 118,124 ---- **/ function _buildComponents() { foreach ($this->_config as $name => $body) { ! list ($alias, $class) = $this->_parseSection($name); $this->_attributes[$alias] = array(); *************** *** 129,139 **** // // 指定されているクラス名が不正だったらエラー // ! if (!preg_match("/^[0-9a-zA-Z.]+$/", $class)) { return false; } $pathList = explode(".", $class); $ucPathList = array(); foreach ($pathList as $path) { --- 129,142 ---- // // 指定されているクラス名が不正だったらエラー // ! if (!preg_match("/^[0-9a-zA-Z.\/]+$/", $class)) { return false; } $pathList = explode(".", $class); + if (count($pathList) == 1) { + $pathList = preg_split('/[\/]/', $pathList[0], -1, PREG_SPLIT_NO_EMPTY); + } $ucPathList = array(); foreach ($pathList as $path) { *************** *** 176,182 **** **/ function _injectAttributes() { foreach ($this->_config as $name => $body) { ! list ($alias, $class) = explode(":", $name); $attributes = array(); --- 179,185 ---- **/ function _injectAttributes() { foreach ($this->_config as $name => $body) { ! list ($alias, $class) = $this->_parseSection($name); $attributes = array(); *************** *** 209,214 **** --- 212,239 ---- } /** + * dicon.iniのセクションを解析する + * + * 以下の2形式を許可する + * 1. [alias:path.to.component] + * 2. [alias -> path/to/component] + * + * @param string $section セクションの文字列 + * @access private + * @since 3.0.0 + */ + function _parseSection($section) + { + if (preg_match("/->/", $section)) { + list ($alias, $class) = array_map('trim', + preg_split("/->/", $section, -1, PREG_SPLIT_NO_EMPTY)); + } else { + list ($alias, $class) = explode(":", $section); + } + return array($alias, $class); + } + + /** * Componentに属性をInjection * * @param Object $component Componentのインスタンス