Example #1
0
 /**
  * @wiki /MVC模式/控制器/网页框架(frame)
  * ==Bean配置数组==
  * {|
  * !属性
  * !类型
  * !默认值
  * !可选
  * !说明
  * |-- --
  * |frameviews
  * |array 
  * |无
  * |可选
  * |子框体视图
  * |}
  */
 public function buildBean(array &$arrConfig, $sNamespace = '*', \org\jecat\framework\bean\BeanFactory $aBeanFactory = null)
 {
     $aBeanFactory = BeanFactory::singleton();
     $aModelContainer = $this->modelContainer();
     foreach ($arrConfig as $sKey => &$item) {
         // 将 frameView:xxxx 转换成 frameViews[] 结构
         if (strpos($sKey, 'frameview:') === 0) {
             $sName = substr($sKey, 10);
             if (!is_array($item)) {
                 throw new BeanConfException("视图Bean配置的 %s 必须是一个数组", $sKey);
             }
             $arrConfig['frameviews'][$sName] =& $item;
         } else {
             if ($sKey == 'frameview') {
                 $arrConfig['frameviews']['frameview'] =& $arrConfig[$sKey];
             }
         }
     }
     // frameViews --------------------
     if (!empty($arrConfig['frameviews'])) {
         foreach ($arrConfig['frameviews'] as $key => &$arrBeanConf) {
             // 自动配置缺少的 class, name 属性
             $aBeanFactory->_typeProperties($arrBeanConf, 'view', is_int($key) ? null : $key, 'name');
             // 默认 class
             if (empty($arrBeanConf['class'])) {
                 $arrBeanConf['class'] = 'view';
             }
             // 默认关闭 vagrant container
             if (!isset($arrBeanConf['vagrantContainer'])) {
                 $arrBeanConf['vagrantContainer'] = false;
             }
             // 创建对象
             $aBean = $aBeanFactory->createBean($arrBeanConf, $sNamespace, false);
             $aBean->setName($arrBeanConf['name']);
             $this->addFrameView($aBean);
             $aBean->buildBean($arrBeanConf, $sNamespace);
             if (!empty($arrBeanConf['model'])) {
                 if (!($aModel = $aModelContainer->getByName($arrBeanConf['model']))) {
                     throw new BeanConfException("视图(%s)的Bean配置属性 model 无效,没有指定的模型:%s", array($aBean->name(), $arrBeanConf['model']));
                 }
                 $aBean->setModel($aModel);
             }
         }
     }
     //
     parent::buildBean($arrConfig, $sNamespace);
 }