/** * Overrides {@link epManagerBase::initialize()} * @param bool $force whether to force initialization * @return bool * @throws epExceptionManager */ protected function initialize($force = false) { // call parent epManagerBase to initialize $status = parent::initialize($force); // check if init'ed before if (!$force && $this->cm_obj_rel) { return true; } // check if epObjectRelation has been compiled include_once EP_SRC_ORM . '/epObjectRelation.php'; if (!($this->cm_obj_rel =& $this->_getMap('epObjectRelation'))) { if (!($this->cm_obj_rel =& $this->_compileClass('epObjectRelation'))) { throw new epExceptionManager('Failed in compiling class epObjectRelation'); return false; } } // append overall table prefix $this->rel_tbl_prefix = $this->getConfigOption('relation_table'); if ($prefix = $this->getConfigOption('table_prefix')) { $this->rel_tbl_prefix = epUnquote($prefix) . $this->rel_tbl_prefix; } // set relation table name $this->cm_obj_rel->setTable($this->rel_tbl_prefix); // set default dsn to relation table $this->cm_obj_rel->setDsn($this->getConfigOption('default_dsn')); // cache relation table splitting flag $this->rel_tbl_split = $this->getConfigOption('split_relation_table'); return $status; }
/** * Parse the comment of the class * @param epClassMap the class map * @param string the comment of the class * @return bool */ protected function parseClassComment(&$cm, $comment) { if (!($c = new epComment($comment))) { throw new epExceptionParser('Cannot parse comment for class [' . $cm->getName() . ']'); return false; } // always harvest 'raw' customer tags $cm->setTags($c->getTags()); if (!($value = $c->getTagValue('orm'))) { return true; } if (!($t = new epClassTag())) { throw new epExceptionParser('Cannot parse @orm tag for class [' . $cm->getName() . ']'); return false; } if (!$t->parse($value)) { throw new epExceptionParser('Cannot parse @orm tag for class [' . $cm->getName() . ']'); return false; } // database table name if ($table = $t->get('table')) { // append prefix to table name if ($prefix = $this->getConfigOption('table_prefix')) { $table = epUnquote($prefix) . $table; } $cm->setTable($table); } // dsn of the database if ($dsn = $t->get('dsn')) { $cm->setDsn($dsn); } else { $cm->setDsn($this->getConfigOption('default_dsn')); } // oid column of the class if ($oid = $t->get('oid')) { $cm->setOidColumn($oid); } else { $cm->setOidColumn($this->getConfigOption('default_oid_column')); } return true; }