/** * Wizard for language. * * @param int $id Language identity. * * @return void|ResponseInterface * * @Route("/wizard/{id:[0-9]+}", methods={"GET", "POST"}, name="admin-languages-wizard") */ public function wizardAction($id) { $item = Language::findFirst($id); if (!$item) { $this->flashSession->error($this->i18n->_('Language not found!')); return $this->response->redirect(['for' => "admin-languages"]); } if ($this->request->isPost()) { $translationId = $this->request->getPost('translation_id'); $translation = LanguageTranslation::findFirstById($translationId); if ($translation) { $translation->translated = $this->request->getPost('translated'); $translation->checked = true; $translation->save(); } } $condition = 'original = translated AND checked = 0 AND language_id = ' . $id; $this->disableFooter(); $this->view->form = $form = new Wizard($item); $this->view->total = LanguageTranslation::find([$condition])->count(); $this->view->translation = $translation = LanguageTranslation::findFirst([$condition]); $this->view->item = $item; if ($translation) { $form->setValues($translation->toArray()); $form->setValue('translation_id', $translation->getId()); } }