59 private $deploymentConfig;
73 ResourceConfigInterface $resourceConfig,
78 $this->config = $resourceConfig;
94 $connectionName = $this->config->getConnectionName($resourceName);
108 if ($resourceName ===
null) {
109 foreach ($this->connections as $processConnection) {
110 if ($processConnection !==
null) {
111 $processConnection->closeConnection();
114 $this->connections = [];
116 $processConnectionName = $this->getProcessConnectionName($this->config->getConnectionName($resourceName));
117 if (isset($this->connections[$processConnectionName])) {
118 if ($this->connections[$processConnectionName] !==
null) {
119 $this->connections[$processConnectionName]->closeConnection();
121 $this->connections[$processConnectionName] =
null;
135 $processConnectionName = $this->getProcessConnectionName($connectionName);
136 if (isset($this->connections[$processConnectionName])) {
137 return $this->connections[$processConnectionName];
140 $connectionConfig = $this->deploymentConfig->get(
144 if ($connectionConfig) {
145 $connection = $this->connectionFactory->create($connectionConfig);
147 throw new \DomainException(
'Connection "' . $connectionName .
'" is not defined');
150 $this->connections[$processConnectionName] =
$connection;
160 private function getProcessConnectionName($connectionName)
162 return $connectionName .
'_process_' . getmypid();
173 public function getTableName($modelEntity, $connectionName = self::DEFAULT_CONNECTION)
176 if (is_array($modelEntity)) {
177 list($modelEntity, $tableSuffix) = $modelEntity;
183 if ($mappedTableName) {
234 $this->mappedTableNames[
$tableName] = $mappedName;
246 if (isset($this->mappedTableNames[
$tableName])) {
264 $indexType = \
Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_INDEX
283 public function getFkName($priTableName, $priColumnName, $refTableName, $refColumnName)
303 return $this->deploymentConfig->get(
318 if ($this->tablePrefix !==
null) {
322 return (
string) $this->deploymentConfig->get(
getConnection($resourceName=self::DEFAULT_CONNECTION)
getIdxName( $tableName, $fields, $indexType=\Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_INDEX)
const CONFIG_PATH_DB_PREFIX
getSchemaName($resourceName)
getTableName($modelEntity, $connectionName=self::DEFAULT_CONNECTION)
getConnectionByName($connectionName)
getTablePlaceholder($tableName)
__construct(ResourceConfigInterface $resourceConfig, ConnectionFactoryInterface $connectionFactory, DeploymentConfig $deploymentConfig, $tablePrefix='')
const CONFIG_PATH_DB_CONNECTIONS
setMappedTableName($tableName, $mappedName)
getTriggerName($tableName, $time, $event)
getMappedTableName($tableName)
closeConnection($resourceName=self::DEFAULT_CONNECTION)
getFkName($priTableName, $priColumnName, $refTableName, $refColumnName)