phprs\util\IoCFactory::__construct PHP Method

__construct() public method

public __construct ( string | array $conf = null, array $dict = null, array $metas = null )
$conf string | array 文件或者配置数组 配置数组格式如下: [ id=>[ "class"=>类名, "singleton"=>false, 是否是单例, 如果是, 则只会创建一份(同一个工厂内) "pass_by_construct"=false, 属性是否通过构造函数传递, 如果不是, 则通过访问属性的方式传递 "properties"=>{ 属性名=>属性值 }
$dict array 设置字典 配置文件中, 属性值可以使用{key}的方式指定模板变量, 注入属性到实例是这些模板变 量会被替换成setDict方法设置的值
$metas array 类元信息, 如果不指定, 则自动从类文件中导出 ]
    public function __construct($conf = null, $dict = null, $metas = null)
    {
        if ($conf === null) {
            $this->conf = array();
        } elseif (is_array($conf)) {
            $this->conf = $conf;
        } else {
            Verify::isTrue(is_file($conf), "{$conf} is not a valid file");
            if (strtolower(pathinfo($conf, PATHINFO_EXTENSION)) == 'php') {
                $this->conf = (include $conf);
            } else {
                Verify::isTrue(false !== ($data = file_get_contents($conf)), "{$conf} open failed");
                $data = self::clearAnnotation($data);
                Verify::isTrue(is_array($this->conf = json_decode($data, true)), "{$conf} json_decode failed with " . json_last_error());
            }
            $this->conf_file = $conf;
        }
        if ($dict !== null) {
            $this->conf = $this->replaceByDict($this->conf, $dict);
        }
        $this->metas = $metas;
    }