コード例 #1
0
 public function getParentRow($rule)
 {
     $ref = $this->_model->getReference($rule);
     if ($ref === Kwf_Model_RowsSubModel_Interface::SUBMODEL_PARENT) {
         if (!$this instanceof Kwf_Model_RowsSubModel_Row_Interface) {
             throw new Kwf_Exception("row '" . get_class($this) . "' must implement Kwf_Model_RowsSubModel_Row_Interface");
         }
         return $this->getSubModelParentRow();
     }
     if (!isset($ref['column'])) {
         throw new Kwf_Exception("column for reference '{$rule}' not set");
     }
     $id = $this->{$ref['column']};
     if (!$id) {
         return null;
     }
     if (isset($ref['refModelClass'])) {
         $refModel = Kwf_Model_Abstract::getInstance($ref['refModelClass']);
     } else {
         if (isset($ref['refModel'])) {
             $refModel = $ref['refModel'];
         } else {
             throw new Kwf_Exception("refModel or refModelClass for reference '{$rule}' not set");
         }
     }
     return $refModel->getRow($id);
 }