Skip to content

Commit 7019f99

Browse files
committed
Merge remote-tracking branch 'falcon/MAGETWO-70216' into falcons-pr-bugfixes-2
2 parents aa4ae30 + 0cb6700 commit 7019f99

File tree

6 files changed

+20
-122
lines changed

6 files changed

+20
-122
lines changed

app/code/Magento/Translation/App/Config/Type/Translation.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
/**
1313
* Class which hold all translation sources and merge them
14+
* @deprecated translation config type was removed
1415
*/
1516
class Translation implements ConfigTypeInterface
1617
{

app/code/Magento/Translation/Model/ResourceModel/Translate.php

Lines changed: 12 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55
*/
66
namespace Magento\Translation\Model\ResourceModel;
77

8-
use Magento\Framework\App\ObjectManager;
9-
use Magento\Framework\App\DeploymentConfig;
10-
use Magento\Framework\App\Config;
11-
use Magento\Translation\App\Config\Type\Translation;
12-
138
class Translate extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb implements
149
\Magento\Framework\Translate\ResourceInterface
1510
{
@@ -23,16 +18,6 @@ class Translate extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb imp
2318
*/
2419
protected $scope;
2520

26-
/**
27-
* @var Config
28-
*/
29-
private $appConfig;
30-
31-
/**
32-
* @var DeploymentConfig
33-
*/
34-
private $deployedConfig;
35-
3621
/**
3722
* @param \Magento\Framework\Model\ResourceModel\Db\Context $context
3823
* @param \Magento\Framework\App\ScopeResolverInterface $scopeResolver
@@ -72,25 +57,21 @@ public function getTranslationArray($storeId = null, $locale = null)
7257
if ($storeId === null) {
7358
$storeId = $this->getStoreId();
7459
}
75-
$locale = (string) $locale;
7660

77-
$data = $this->getAppConfig()->get(
78-
Translation::CONFIG_TYPE,
79-
$locale . '/' . $this->getStoreCode($storeId),
80-
[]
81-
);
8261
$connection = $this->getConnection();
83-
if ($connection) {
84-
$select = $connection->select()
85-
->from($this->getMainTable(), ['string', 'translate'])
86-
->where('store_id IN (0 , :store_id)')
87-
->where('locale = :locale')
88-
->order('store_id');
89-
$bind = [':locale' => $locale, ':store_id' => $storeId];
90-
$dbData = $connection->fetchPairs($select, $bind);
91-
$data = array_replace($data, $dbData);
62+
if (!$connection) {
63+
return [];
9264
}
93-
return $data;
65+
66+
$select = $connection->select()
67+
->from($this->getMainTable(), ['string', 'translate'])
68+
->where('store_id IN (0 , :store_id)')
69+
->where('locale = :locale')
70+
->order('store_id');
71+
72+
$bind = [':locale' => (string)$locale, ':store_id' => $storeId];
73+
74+
return $connection->fetchPairs($select, $bind);
9475
}
9576

9677
/**
@@ -134,19 +115,6 @@ public function getMainChecksum()
134115
return $this->getChecksum($this->getMainTable());
135116
}
136117

137-
/**
138-
* Get connection
139-
*
140-
* @return \Magento\Framework\DB\Adapter\AdapterInterface|false
141-
*/
142-
public function getConnection()
143-
{
144-
if (!$this->getDeployedConfig()->isDbAvailable()) {
145-
return false;
146-
}
147-
return parent::getConnection();
148-
}
149-
150118
/**
151119
* Retrieve current store identifier
152120
*
@@ -156,39 +124,4 @@ protected function getStoreId()
156124
{
157125
return $this->scopeResolver->getScope($this->scope)->getId();
158126
}
159-
160-
/**
161-
* Retrieve store code by store id
162-
*
163-
* @param int $storeId
164-
* @return string
165-
*/
166-
private function getStoreCode($storeId)
167-
{
168-
return $this->scopeResolver->getScope($storeId)->getCode();
169-
}
170-
171-
/**
172-
* @deprecated
173-
* @return DeploymentConfig
174-
*/
175-
private function getDeployedConfig()
176-
{
177-
if ($this->deployedConfig === null) {
178-
$this->deployedConfig = ObjectManager::getInstance()->get(DeploymentConfig::class);
179-
}
180-
return $this->deployedConfig;
181-
}
182-
183-
/**
184-
* @deprecated
185-
* @return Config
186-
*/
187-
private function getAppConfig()
188-
{
189-
if ($this->appConfig === null) {
190-
$this->appConfig = ObjectManager::getInstance()->get(Config::class);
191-
}
192-
return $this->appConfig;
193-
}
194127
}

app/code/Magento/Translation/Model/Source/InitialTranslationSource.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
/**
1616
* Class for reading translations from DB
17+
*
18+
* @deprecated translation config source was removed. This class is not used anymore
19+
* @see app/code/Magento/Translation/Model/ResourceModel/Translate.php
1720
*/
1821
class InitialTranslationSource implements ConfigSourceInterface
1922
{

app/code/Magento/Translation/Test/Unit/App/Config/Type/TranslationTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
/**
1616
* @covers \Magento\Translation\App\Config\Type\Translation
17+
*
18+
* @deprecated translation config source was removed.
1719
*/
1820
class TranslationTest extends \PHPUnit_Framework_TestCase
1921
{

app/code/Magento/Translation/Test/Unit/Model/Source/InitialTranslationSourceTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
* @covers \Magento\Translation\Model\Source\InitialTranslationSource
1919
* @package Magento\Translation\Test\Unit\Model\Source
2020
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
21+
*
22+
* @deprecated translation config source was removed.
2123
*/
2224
class InitialTranslationSourceTest extends \PHPUnit_Framework_TestCase
2325
{

app/code/Magento/Translation/etc/di.xml

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -93,47 +93,4 @@
9393
</argument>
9494
</arguments>
9595
</type>
96-
<virtualType name="translationConfigInitialDataProvider" type="Magento\Framework\App\Config\InitialConfigSource">
97-
<arguments>
98-
<argument name="reader" xsi:type="object">Magento\Framework\App\DeploymentConfig\Reader</argument>
99-
<argument name="configType" xsi:type="const">Magento\Translation\App\Config\Type\Translation::CONFIG_TYPE</argument>
100-
<argument name="fileKey" xsi:type="const">Magento\Framework\Config\File\ConfigFilePool::APP_CONFIG</argument>
101-
</arguments>
102-
</virtualType>
103-
<virtualType name="translationConfigSourceAggregated" type="Magento\Framework\App\Config\ConfigSourceAggregated">
104-
<arguments>
105-
<argument name="sources" xsi:type="array">
106-
<item name="dynamic" xsi:type="array">
107-
<item name="source" xsi:type="object">Magento\Translation\Model\Source\InitialTranslationSource\Proxy</item>
108-
<item name="sortOrder" xsi:type="string">100</item>
109-
</item>
110-
<item name="initial" xsi:type="array">
111-
<item name="source" xsi:type="object">translationConfigInitialDataProvider</item>
112-
<item name="sortOrder" xsi:type="string">1000</item>
113-
</item>
114-
</argument>
115-
</arguments>
116-
</virtualType>
117-
<type name="Magento\Translation\App\Config\Type\Translation">
118-
<arguments>
119-
<argument name="source" xsi:type="object">translationConfigSourceAggregated</argument>
120-
</arguments>
121-
</type>
122-
<type name="Magento\Framework\App\Config">
123-
<arguments>
124-
<argument name="types" xsi:type="array">
125-
<item name="i18n" xsi:type="object">Magento\Translation\App\Config\Type\Translation</item>
126-
</argument>
127-
</arguments>
128-
</type>
129-
<type name="Magento\Deploy\Console\Command\App\ApplicationDumpCommand">
130-
<arguments>
131-
<argument name="sources" xsi:type="array">
132-
<item name="i18n" xsi:type="array">
133-
<item name="source" xsi:type="object">Magento\Translation\Model\Source\InitialTranslationSource</item>
134-
<item name="namespace" xsi:type="const">Magento\Translation\App\Config\Type\Translation::CONFIG_TYPE</item>
135-
</item>
136-
</argument>
137-
</arguments>
138-
</type>
13996
</config>

0 commit comments

Comments
 (0)