From be1e5d1d3e140e595534aff46a877982dafd0b88 Mon Sep 17 00:00:00 2001 From: ADmad Date: Fri, 29 Nov 2024 20:56:01 +0530 Subject: [PATCH] code cleanup --- src/Command/I18nExtractCommand.php | 34 +++++++++++++++--------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Command/I18nExtractCommand.php b/src/Command/I18nExtractCommand.php index 5cfa4ae..000497d 100644 --- a/src/Command/I18nExtractCommand.php +++ b/src/Command/I18nExtractCommand.php @@ -218,7 +218,7 @@ 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')); } @@ -226,7 +226,7 @@ protected function _saveMessages(Arguments $args, ConsoleIo $io): void $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) { @@ -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); } }