Updated entity mappings so that schema an table prefixes can be eventually provided

This commit is contained in:
Alejandro Celaya
2020-01-29 10:53:06 +01:00
parent 96350c8b8f
commit bd2f488e2c
8 changed files with 30 additions and 15 deletions

View File

@@ -8,6 +8,8 @@ use Cake\Chronos\Chronos;
use DateTimeInterface;
use PUGX\Shortid\Factory as ShortIdFactory;
use function sprintf;
function generateRandomShortCode(int $length = 5): string
{
static $shortIdFactory;
@@ -39,3 +41,15 @@ function parseDateField($date): ?Chronos
return Chronos::parse($date);
}
function determineTableName(string $tableName, array $emConfig = []): string
{
$schema = $emConfig['connection']['schema'] ?? null;
// $tablePrefix = $emConfig['connection']['table_prefix'] ?? null; // TODO
if ($schema === null) {
return $tableName;
}
return sprintf('%s.%s', $schema, $tableName);
}