diff --git a/src/Model/ModelRegistry.php b/src/Model/ModelRegistry.php index 3f0defe08..98ac1fe93 100644 --- a/src/Model/ModelRegistry.php +++ b/src/Model/ModelRegistry.php @@ -146,14 +146,17 @@ private function generateModelName(Model $model): string ); $i = 1; while (\in_array($name, $names, true)) { - if (isset($this->registeredModelNames[$name])) { - $this->logger->info(sprintf('Can not assign a name for the model, the name "%s" has already been taken.', $name), [ + ++$i; + $name = $base.$i; + } + + if ($i > 1) { + if (isset($this->registeredModelNames[$base])) { + $this->logger->info(sprintf('Can not assign a name for the model, the name "%s" has already been taken.', $base), [ 'model' => $this->modelToArray($model), - 'taken_by' => $this->modelToArray($this->registeredModelNames[$name]), + 'taken_by' => $this->modelToArray($this->registeredModelNames[$base]), ]); } - ++$i; - $name = $base.$i; } return $name;