Skip to content

Commit 4a83bfb

Browse files
committed
Refactor ResourceConnection.php
1 parent 25772e6 commit 4a83bfb

File tree

1 file changed

+16
-23
lines changed

1 file changed

+16
-23
lines changed

lib/internal/Magento/Framework/App/ResourceConnection.php

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Framework\App;
79

810
use Magento\Framework\App\ResourceConnection\ConfigInterface as ResourceConfigInterface;
@@ -18,13 +20,10 @@
1820
*/
1921
class ResourceConnection
2022
{
21-
const AUTO_UPDATE_ONCE = 0;
22-
23-
const AUTO_UPDATE_NEVER = -1;
24-
25-
const AUTO_UPDATE_ALWAYS = 1;
26-
27-
const DEFAULT_CONNECTION = 'default';
23+
public const AUTO_UPDATE_ONCE = 0;
24+
public const AUTO_UPDATE_NEVER = -1;
25+
public const AUTO_UPDATE_ALWAYS = 1;
26+
public const DEFAULT_CONNECTION = 'default';
2827

2928
/**
3029
* Instances of actual connections.
@@ -93,8 +92,7 @@ public function __construct(
9392
public function getConnection($resourceName = self::DEFAULT_CONNECTION)
9493
{
9594
$connectionName = $this->config->getConnectionName($resourceName);
96-
$connection = $this->getConnectionByName($connectionName);
97-
return $connection;
95+
return $this->getConnectionByName($connectionName);
9896
}
9997

10098
/**
@@ -160,13 +158,13 @@ public function getConnectionByName($connectionName)
160158
*/
161159
private function getProcessConnectionName($connectionName)
162160
{
163-
return $connectionName . '_process_' . getmypid();
161+
return $connectionName . '_process_' . getmypid();
164162
}
165163

166164
/**
167165
* Get resource table name, validated by db adapter.
168166
*
169-
* @param string|string[] $modelEntity
167+
* @param string|string[] $modelEntity
170168
* @param string $connectionName
171169
* @return string
172170
* @api
@@ -212,9 +210,9 @@ public function getTablePlaceholder($tableName)
212210
/**
213211
* Build a trigger name.
214212
*
215-
* @param string $tableName The table that is the subject of the trigger
216-
* @param string $time Either "before" or "after"
217-
* @param string $event The DB level event which activates the trigger, i.e. "update" or "insert"
213+
* @param string $tableName The table that is the subject of the trigger
214+
* @param string $time Either "before" or "after"
215+
* @param string $event The DB level event which activates the trigger, i.e. "update" or "insert"
218216
* @return string
219217
*/
220218
public function getTriggerName($tableName, $time, $event)
@@ -275,9 +273,9 @@ public function getIdxName(
275273
/**
276274
* Retrieve 32bit UNIQUE HASH for a Table foreign key.
277275
*
278-
* @param string $priTableName the target table name
276+
* @param string $priTableName the target table name
279277
* @param string $priColumnName the target table column name
280-
* @param string $refTableName the reference table name
278+
* @param string $refTableName the reference table name
281279
* @param string $refColumnName the reference table column name
282280
* @return string
283281
*/
@@ -302,10 +300,7 @@ public function getFkName($priTableName, $priColumnName, $refTableName, $refColu
302300
public function getSchemaName($resourceName)
303301
{
304302
return $this->deploymentConfig->get(
305-
ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTIONS .
306-
'/' .
307-
$resourceName .
308-
'/dbname'
303+
ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTIONS . '/' . $resourceName . '/dbname'
309304
);
310305
}
311306

@@ -320,8 +315,6 @@ public function getTablePrefix()
320315
return $this->tablePrefix;
321316
}
322317

323-
return (string) $this->deploymentConfig->get(
324-
ConfigOptionsListConstants::CONFIG_PATH_DB_PREFIX
325-
);
318+
return (string)$this->deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_DB_PREFIX);
326319
}
327320
}

0 commit comments

Comments
 (0)