예제 #1
0
 public function createChildRow($rule, array $data = array())
 {
     if ($rule instanceof Kwf_Model_Abstract) {
         $m = $rule;
         $dependentOf = $this->_model;
     } else {
         $dependent = $this->_model->getDependentModelWithDependentOf($rule);
         $m = $dependent['model'];
         $dependentOf = $dependent['dependentOf'];
     }
     if ($m instanceof Kwf_Model_RowsSubModel_Interface) {
         $ret = $m->createRowByParentRow($this, $data);
     } else {
         $ret = $m->createRow($data);
         $ref = $m->getReferenceByModelClass(get_class($dependentOf), isset($dependent['rule']) ? $dependent['rule'] : null);
         $ret->{$ref['column']} = $this->{$this->_getPrimaryKey()};
     }
     $rule = isset($dependent['rule']) ? $dependent['rule'] : '';
     if (!isset($this->_childRows[$rule])) {
         $this->_childRows[$rule] = array();
     }
     $this->_childRows[$rule][] = $ret;
     return $ret;
 }