Skip to content

Commit be1e5d1

Browse files
committed
code cleanup
1 parent c9355a8 commit be1e5d1

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/Command/I18nExtractCommand.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,15 @@ protected function _saveMessages(Arguments $args, ConsoleIo $io): void
218218
return strlen($a) - strlen($b);
219219
});
220220

221-
$domains = null;
221+
$domains = [];
222222
if ($args->hasOption('domains')) {
223223
$domains = explode(',', (string)$args->getOption('domains'));
224224
}
225225

226226
$this->_loadModel($args);
227227

228228
foreach ($this->_translations as $domain => $translations) {
229-
if (!empty($domains) && !in_array($domain, $domains)) {
229+
if ($domains && !in_array($domain, $domains)) {
230230
continue;
231231
}
232232
if ($this->_merge) {
@@ -277,22 +277,22 @@ protected function _save(
277277
?string $refs = null
278278
): void {
279279
foreach ($this->_languages as $locale) {
280-
$found = $this->_model->find()
281-
->where(compact('domain', 'locale', 'singular'))
282-
->count();
283-
284-
if (!$found) {
285-
$entity = $this->_model->newEntity(compact(
286-
'domain',
287-
'locale',
288-
'singular',
289-
'plural',
290-
'context',
291-
'refs'
292-
), ['guard' => false]);
293-
294-
$this->_model->save($entity);
280+
if (
281+
$this->_model->exists(compact('domain', 'locale', 'singular'))
282+
) {
283+
continue;
295284
}
285+
286+
$entity = $this->_model->newEntity(compact(
287+
'domain',
288+
'locale',
289+
'singular',
290+
'plural',
291+
'context',
292+
'refs'
293+
), ['guard' => false]);
294+
295+
$this->_model->save($entity);
296296
}
297297
}
298298

0 commit comments

Comments
 (0)