/** * An utility method to add a new table from an xml attribute. */ public function addTable($data) { if ($data instanceof Table) { $tbl = $data; // alias $tbl->setDatabase($this); if (isset($this->tablesByName[$tbl->getName()])) { throw new EngineException("Duplicate table declared: " . $tbl->getName()); } $this->tableList[] = $tbl; $this->tablesByName[$tbl->getName()] = $tbl; $this->tablesByPhpName[$tbl->getPhpName()] = $tbl; if ($tbl->getPackage() === null) { $tbl->setPackage($this->getPackage()); } return $tbl; } else { $tbl = new Table(); $tbl->setDatabase($this); $tbl->loadFromXML($data); return $this->addTable($tbl); // call self w/ different param } }
/** * An utility method to add a new table from an xml attribute. */ public function addTable($data) { if ($data instanceof Table) { $tbl = $data; // alias $tbl->setDatabase($this); if (isset($this->tablesByName[$tbl->getName()])) { throw new EngineException(sprintf('Table "%s" declared twice', $tbl->getName())); } if ($tbl->getSchema() === null) { $tbl->setSchema($this->getSchema()); } $this->tableList[] = $tbl; $this->tablesByName[$tbl->getName()] = $tbl; $this->tablesByLowercaseName[strtolower($tbl->getName())] = $tbl; $this->tablesByPhpName[$tbl->getPhpName()] = $tbl; if (strpos($tbl->getNamespace(), '\\') === 0) { $tbl->setNamespace(substr($tbl->getNamespace(), 1)); } elseif ($namespace = $this->getNamespace()) { if ($tbl->getNamespace() === null) { $tbl->setNamespace($namespace); } else { $tbl->setNamespace($namespace . '\\' . $tbl->getNamespace()); } } if ($tbl->getPackage() === null) { $tbl->setPackage($this->getPackage()); } return $tbl; } else { $tbl = new Table(); $tbl->setDatabase($this); $tbl->setSchema($this->getSchema()); $tbl->loadFromXML($data); return $this->addTable($tbl); // call self w/ different param } }
/** * Adds Domain object from <domain> tag. * @param mixed XML attributes (array) or Domain object. */ public function addDomain($data) { if ($data instanceof Domain) { $domain = $data; // alias $domain->setDatabase($this); $this->domainMap[$domain->getName()] = $domain; return $domain; } else { $domain = new Table(); $domain->setDatabase($this); $domain->loadFromXML($data); return $this->addDomain($domain); // call self w/ different param } }