Skip to content

Commit 2fb5735

Browse files
committed
MAGETWO-81801: Prepare code base 2.2.1
1 parent d2cbddd commit 2fb5735

File tree

6 files changed

+172
-151
lines changed

6 files changed

+172
-151
lines changed

app/code/Magento/Deploy/Model/Filesystem.php

Lines changed: 30 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@
55
*/
66
namespace Magento\Deploy\Model;
77

8-
use Symfony\Component\Console\Output\OutputInterface;
9-
use Magento\Framework\App\State;
10-
use Magento\Framework\App\DeploymentConfig\Writer;
118
use Magento\Framework\App\Filesystem\DirectoryList;
129
use Magento\Framework\Exception\LocalizedException;
10+
use Magento\Framework\Validator\Locale;
1311
use Magento\User\Model\ResourceModel\User\Collection as UserCollection;
12+
use Symfony\Component\Console\Output\OutputInterface;
1413

1514
/**
1615
* Generate static files, compile
1716
*
18-
* Сlear generated/code, generated/metadata/, var/view_preprocessed and pub/static directories
17+
* Clear generated/code, generated/metadata/, var/view_preprocessed and pub/static directories
1918
*
2019
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2120
*/
@@ -50,21 +49,6 @@ class Filesystem
5049
*/
5150
const DEFAULT_THEME = 'Magento/blank';
5251

53-
/**
54-
* @var \Magento\Framework\App\DeploymentConfig\Writer
55-
*/
56-
private $writer;
57-
58-
/**
59-
* @var \Magento\Framework\App\DeploymentConfig\Reader
60-
*/
61-
private $reader;
62-
63-
/**
64-
* @var \Magento\Framework\ObjectManagerInterface
65-
*/
66-
private $objectManager;
67-
6852
/**
6953
* @var \Magento\Framework\Filesystem
7054
*/
@@ -101,33 +85,35 @@ class Filesystem
10185
private $userCollection;
10286

10387
/**
104-
* @param \Magento\Framework\App\DeploymentConfig\Writer $writer
105-
* @param \Magento\Framework\App\DeploymentConfig\Reader $reader
106-
* @param \Magento\Framework\ObjectManagerInterface $objectManager
88+
* @var Locale
89+
*/
90+
private $locale;
91+
92+
/**
10793
* @param \Magento\Framework\Filesystem $filesystem
10894
* @param \Magento\Framework\App\Filesystem\DirectoryList $directoryList
10995
* @param \Magento\Framework\Filesystem\Driver\File $driverFile
11096
* @param \Magento\Store\Model\Config\StoreView $storeView
11197
* @param \Magento\Framework\ShellInterface $shell
98+
* @param UserCollection $userCollection
99+
* @param Locale $locale
112100
*/
113101
public function __construct(
114-
\Magento\Framework\App\DeploymentConfig\Writer $writer,
115-
\Magento\Framework\App\DeploymentConfig\Reader $reader,
116-
\Magento\Framework\ObjectManagerInterface $objectManager,
117102
\Magento\Framework\Filesystem $filesystem,
118103
\Magento\Framework\App\Filesystem\DirectoryList $directoryList,
119104
\Magento\Framework\Filesystem\Driver\File $driverFile,
120105
\Magento\Store\Model\Config\StoreView $storeView,
121-
\Magento\Framework\ShellInterface $shell
106+
\Magento\Framework\ShellInterface $shell,
107+
UserCollection $userCollection,
108+
Locale $locale
122109
) {
123-
$this->writer = $writer;
124-
$this->reader = $reader;
125-
$this->objectManager = $objectManager;
126110
$this->filesystem = $filesystem;
127111
$this->directoryList = $directoryList;
128112
$this->driverFile = $driverFile;
129113
$this->storeView = $storeView;
130114
$this->shell = $shell;
115+
$this->userCollection = $userCollection;
116+
$this->locale = $locale;
131117
$this->functionCallPath =
132118
PHP_BINARY . ' -f ' . BP . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'magento ';
133119
}
@@ -141,7 +127,7 @@ public function __construct(
141127
public function regenerateStatic(
142128
OutputInterface $output
143129
) {
144-
// Сlear generated/code, generated/metadata/, var/view_preprocessed and pub/static directories
130+
// Clear generated/code, generated/metadata/, var/view_preprocessed and pub/static directories
145131
$this->cleanupFilesystem(
146132
[
147133
DirectoryList::CACHE,
@@ -193,7 +179,7 @@ protected function deployStaticContent(
193179
private function getAdminUserInterfaceLocales()
194180
{
195181
$locales = [];
196-
foreach ($this->getUserCollection() as $user) {
182+
foreach ($this->userCollection as $user) {
197183
$locales[] = $user->getInterfaceLocale();
198184
}
199185
return $locales;
@@ -203,32 +189,26 @@ private function getAdminUserInterfaceLocales()
203189
* Get used store and admin user locales
204190
*
205191
* @return array
192+
* @throws \InvalidArgumentException if unknown locale is provided by the store configuration
206193
*/
207194
private function getUsedLocales()
208195
{
209196
$usedLocales = array_merge(
210197
$this->storeView->retrieveLocales(),
211198
$this->getAdminUserInterfaceLocales()
212199
);
213-
return array_unique($usedLocales);
214-
}
215-
216-
/**
217-
* Get user collection
218-
*
219-
* @return UserCollection
220-
* @deprecated 100.1.0 Added to not break backward compatibility of the constructor signature
221-
* by injecting the new dependency directly.
222-
* The method can be removed in a future major release, when constructor signature can be changed.
223-
*/
224-
private function getUserCollection()
225-
{
226-
if (!($this->userCollection instanceof UserCollection)) {
227-
return \Magento\Framework\App\ObjectManager::getInstance()->get(
228-
UserCollection::class
229-
);
230-
}
231-
return $this->userCollection;
200+
return array_map(
201+
function ($locale) {
202+
if (!$this->locale->isValid($locale)) {
203+
throw new \InvalidArgumentException(
204+
$locale .
205+
' argument has invalid value, run info:language:list for list of available locales'
206+
);
207+
}
208+
return $locale;
209+
},
210+
array_unique($usedLocales)
211+
);
232212
}
233213

234214
/**

0 commit comments

Comments
 (0)