/** * Generates Cough classes from a Schema object. * * @param Schema $schema * @return void * @author Anthony Bush **/ public function generateCoughClassesFromSchema(Schema $schema) { foreach ($schema->getDatabases() as $database) { foreach ($database->getTables() as $table) { $this->generateCoughClassesFromSchemaTable($table); } } }
/** * Scans the schema for the specified table name (or prefix + table name), * starting with the given database and only scanning other databases if * the table is not found there. * * @return mixed - SchemaTable if found, null if not * @author Anthony Bush **/ protected function findTable($tableNameMatch, SchemaTable $sourceTable) { $firstDatabase = $sourceTable->getDatabase(); $table = $this->findTableInDatabase($tableNameMatch, $firstDatabase); if (is_null($table)) { // Try again for every other database $firstDatabaseName = $firstDatabase->getDatabaseName(); foreach ($this->schema->getDatabases() as $dbName => $database) { if ($dbName == $firstDatabaseName || !$this->config->shouldScanForJoin($sourceTable, $database)) { continue; } $table = $this->findTableInDatabase($tableNameMatch, $database); if (!is_null($table)) { break; } } } return $table; }