Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Nov 29, 2024
1 parent c9355a8 commit be1e5d1
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/Command/I18nExtractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,15 @@ protected function _saveMessages(Arguments $args, ConsoleIo $io): void
return strlen($a) - strlen($b);
});

$domains = null;
$domains = [];
if ($args->hasOption('domains')) {
$domains = explode(',', (string)$args->getOption('domains'));
}

$this->_loadModel($args);

foreach ($this->_translations as $domain => $translations) {
if (!empty($domains) && !in_array($domain, $domains)) {
if ($domains && !in_array($domain, $domains)) {
continue;
}
if ($this->_merge) {
Expand Down Expand Up @@ -277,22 +277,22 @@ protected function _save(
?string $refs = null
): void {
foreach ($this->_languages as $locale) {
$found = $this->_model->find()
->where(compact('domain', 'locale', 'singular'))
->count();

if (!$found) {
$entity = $this->_model->newEntity(compact(
'domain',
'locale',
'singular',
'plural',
'context',
'refs'
), ['guard' => false]);

$this->_model->save($entity);
if (
$this->_model->exists(compact('domain', 'locale', 'singular'))
) {
continue;
}

$entity = $this->_model->newEntity(compact(
'domain',
'locale',
'singular',
'plural',
'context',
'refs'
), ['guard' => false]);

$this->_model->save($entity);
}
}

Expand Down

0 comments on commit be1e5d1

Please sign in to comment.