protected function cleanBeforeBuild(Schema $schema) { $rootPath = $this->config->getTargetRootFolder() . '/' . $this->config->getModelRootNamespace() . (!$schema->isSingle() ? '/' . $schema->getName(true) : ''); $schemaPath = $rootPath . '/Schema'; if ($this->fileSystem->exists($schemaPath)) { $this->fileSystem->remove($schemaPath); } }
/** * Loads the Relations fro a given schema * @param Schema $schema */ protected function loadRelationsForSchema(Schema $schema) { $sql = new SelectStatement(); $sql->from('information_schema.tables')->selectAll()->where(sqlstr('table_schema')->equalsTo(':table_schema')); $params = [':table_schema' => $schema->getName()]; foreach ($this->database->executeQuery($sql, $params) as $record) { $relation = new Relation($record); $schema->addRelation($relation); $this->loadColumnsForRelation($relation); $this->loadContraintsForRelation($relation); } }