groupName, []); $errors = []; foreach ($this->translated->toArray() as $key => $parts) { if (!isset($data[$key]) || count($data[$key]) !== $parts) { $errors[] = $key; continue; } $translated[$key] = implode(' ', $data[$key]); } if (empty($data) || !empty($errors)) { throw new AfterTranslateException('Part or all of the text has not been translated. Keys: ' . implode(', ', $errors)); } $objectAfterTranslate = $application->make($this->afterTranslateDto->getClassName()); if (!$objectAfterTranslate instanceof \KorElf\TranslateLaravel\Contracts\TranslationCompletedListener) { throw new AfterTranslateException('The class must implement the \KorElf\TranslateLaravel\Contracts\TranslationCompletedListener interface.'); } $objectAfterTranslate->onTranslationCompleted($translated, $this->afterTranslateDto->getData()); Cache::forget($this->groupName); } }