ref
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2023 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Utils\Database;
|
||||
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
|
||||
class MetadataProvider
|
||||
{
|
||||
private const DEFAULT_ID_LENGTH = 24;
|
||||
private const DEFAULT_ID_DB_TYPE = Types::STRING;
|
||||
|
||||
public function __construct(private Metadata $metadata)
|
||||
{}
|
||||
|
||||
public function getIdLength(): int
|
||||
{
|
||||
return $this->metadata->get(['app', 'recordId', 'length']) ??
|
||||
self::DEFAULT_ID_LENGTH;
|
||||
}
|
||||
|
||||
public function getIdDbType(): string
|
||||
{
|
||||
return $this->metadata->get(['app', 'recordId', 'dbType']) ??
|
||||
self::DEFAULT_ID_DB_TYPE;
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ namespace Espo\Core\Utils\Database\Orm;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Espo\Core\InjectableFactory;
|
||||
use Espo\Core\Utils\Database\ConfigDataProvider;
|
||||
use Espo\Core\Utils\Database\MetadataProvider;
|
||||
use Espo\Core\Utils\Util;
|
||||
use Espo\ORM\Defs\AttributeDefs;
|
||||
use Espo\ORM\Defs\FieldDefs;
|
||||
@@ -90,9 +91,6 @@ class Converter
|
||||
/** @var array<string, mixed> */
|
||||
private $idParams = [];
|
||||
|
||||
private const DEFAULT_ID_LENGTH = 24;
|
||||
private const DEFAULT_ID_DB_TYPE = Types::STRING;
|
||||
|
||||
/**
|
||||
* Permitted entityDefs parameters which will be copied to ormMetadata.
|
||||
*
|
||||
@@ -111,17 +109,15 @@ class Converter
|
||||
private MetadataHelper $metadataHelper,
|
||||
private InjectableFactory $injectableFactory,
|
||||
ConfigDataProvider $configDataProvider,
|
||||
IndexHelperFactory $indexHelperFactory
|
||||
IndexHelperFactory $indexHelperFactory,
|
||||
MetadataProvider $metadataProvider
|
||||
) {
|
||||
$platform = $configDataProvider->getPlatform();
|
||||
|
||||
$this->indexHelper = $indexHelperFactory->create($platform);
|
||||
|
||||
$this->idParams['len'] = $this->metadata->get(['app', 'recordId', 'length']) ??
|
||||
self::DEFAULT_ID_LENGTH;
|
||||
|
||||
$this->idParams['dbType'] = $this->metadata->get(['app', 'recordId', 'dbType']) ??
|
||||
self::DEFAULT_ID_DB_TYPE;
|
||||
$this->idParams['len'] = $metadataProvider->getIdLength();
|
||||
$this->idParams['dbType'] = $metadataProvider->getIdDbType();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
namespace Espo\Core\Utils\Database\Schema;
|
||||
|
||||
use Espo\Core\Utils\Database\ConfigDataProvider;
|
||||
use Espo\Core\Utils\Database\MetadataProvider as MetadataProvider;
|
||||
use Espo\Core\Utils\File\Manager as FileManager;
|
||||
use Espo\Core\Utils\Log;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
@@ -53,13 +54,10 @@ use Doctrine\DBAL\Types\Type as DbalType;
|
||||
*/
|
||||
class Builder
|
||||
{
|
||||
private const DEFAULT_ID_LENGTH = 24;
|
||||
private const DEFAULT_ID_DB_TYPE = Types::STRING;
|
||||
|
||||
private const ATTR_ID = 'id';
|
||||
private const ATTR_DELETED = 'deleted';
|
||||
|
||||
private string $idLength;
|
||||
private int $idLength;
|
||||
private string $idDbType;
|
||||
|
||||
private string $tablesPath = 'Core/Utils/Database/Schema/tables';
|
||||
@@ -73,7 +71,8 @@ class Builder
|
||||
private Log $log,
|
||||
private PathProvider $pathProvider,
|
||||
ConfigDataProvider $configDataProvider,
|
||||
ColumnPreparatorFactory $columnPreparatorFactory
|
||||
ColumnPreparatorFactory $columnPreparatorFactory,
|
||||
MetadataProvider $metadataProvider
|
||||
) {
|
||||
$this->typeList = array_keys(DbalType::getTypesMap());
|
||||
|
||||
@@ -81,11 +80,8 @@ class Builder
|
||||
|
||||
$this->columnPreparator = $columnPreparatorFactory->create($platform);
|
||||
|
||||
$this->idLength = $this->metadata->get(['app', 'recordId', 'length']) ??
|
||||
self::DEFAULT_ID_LENGTH;
|
||||
|
||||
$this->idDbType = $this->metadata->get(['app', 'recordId', 'dbType']) ??
|
||||
self::DEFAULT_ID_DB_TYPE;
|
||||
$this->idLength = $metadataProvider->getIdLength();
|
||||
$this->idDbType = $metadataProvider->getIdDbType();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user