diff --git a/src/Form/Model/SurveyConditionData.php b/src/Form/Model/SurveyConditionData.php deleted file mode 100644 index 31258e5..0000000 --- a/src/Form/Model/SurveyConditionData.php +++ /dev/null @@ -1,36 +0,0 @@ -sourceQuestion = (int) $condition->sourceQuestion; - $data->answerValue = (string) $condition->answerValue; - $data->targetQuestion = (int) $condition->targetQuestion; - - return $data; - } - - /** - * @return array - */ - public function toArray(): array - { - return [ - 'sourceQuestion' => $this->sourceQuestion, - 'answerValue' => $this->answerValue, - 'targetQuestion' => $this->targetQuestion, - ]; - } -} \ No newline at end of file diff --git a/src/Form/SurveyConditionEditorType.php b/src/Form/SurveyConditionEditorType.php deleted file mode 100644 index 2d88149..0000000 --- a/src/Form/SurveyConditionEditorType.php +++ /dev/null @@ -1,48 +0,0 @@ -add('sourceQuestion', ChoiceType::class, [ - 'label' => 'Ausgangsfrage', - 'choices' => array_flip($questionChoices), - 'constraints' => [new NotBlank()], - ]) - ->add('answerValue', TextType::class, [ - 'label' => 'Antwort', - 'help' => 'Bei Ja-Nein-Fragen bitte genau ja oder nein eintragen, bei aktivierter Vielleicht-Option auch vielleicht. Bei Choice-Fragen den exakten Antworttext verwenden, bei Multiple-Choice mehrere Werte mit | trennen.', - 'constraints' => [new NotBlank(), new Length(['max' => 255])], - ]) - ->add('targetQuestion', ChoiceType::class, [ - 'label' => 'Nächste Frage', - 'choices' => array_flip($questionChoices), - 'constraints' => [new NotBlank()], - ]) - ; - } - - public function configureOptions(OptionsResolver $resolver): void - { - $resolver->setDefaults([ - 'data_class' => SurveyConditionData::class, - 'question_choices' => [], - ]); - } -} \ No newline at end of file diff --git a/src/Repository/SurveyConditionRepository.php b/src/Repository/SurveyConditionRepository.php index 8dfa675..4ed4658 100644 --- a/src/Repository/SurveyConditionRepository.php +++ b/src/Repository/SurveyConditionRepository.php @@ -72,17 +72,6 @@ final class SurveyConditionRepository return $this->findById($id) ?? throw new \RuntimeException('Bedingung konnte nicht angelegt werden.'); } - public function update(SurveyConditionModel $condition, array $data): void - { - $this->connection->update('tl_survey_condition', [ - 'sourceQuestion' => (int) ($data['sourceQuestion'] ?? $condition->sourceQuestion), - 'answerValue' => mb_strtolower(trim((string) ($data['answerValue'] ?? $condition->answerValue))), - 'targetQuestion' => (int) ($data['targetQuestion'] ?? $condition->targetQuestion), - ], [ - 'id' => (int) $condition->id, - ]); - } - public function delete(int $surveyId, int $conditionId): void { $this->connection->delete('tl_survey_condition', [ diff --git a/src/Service/SurveyEditorService.php b/src/Service/SurveyEditorService.php index 05008d4..db83f25 100644 --- a/src/Service/SurveyEditorService.php +++ b/src/Service/SurveyEditorService.php @@ -5,7 +5,6 @@ declare(strict_types=1); namespace Mummert\SurveyBundle\Service; use Doctrine\DBAL\Connection; -use Mummert\SurveyBundle\Form\Model\SurveyConditionData; use Mummert\SurveyBundle\Form\Model\SurveyEditorData; use Mummert\SurveyBundle\Form\Model\SurveyQuestionData; use Mummert\SurveyBundle\Model\SurveyContentModel; @@ -220,27 +219,6 @@ final class SurveyEditorService }); } - public function saveCondition(SurveyModel $survey, SurveyConditionData $data, int $conditionId = 0): void - { - $this->assertUnlocked($survey); - - if ($conditionId > 0) { - $condition = $this->surveyConditionRepository->findById($conditionId); - - if (null === $condition || (int) $condition->pid !== (int) $survey->id) { - throw new \RuntimeException('Die Bedingung wurde nicht gefunden.'); - } - - $this->surveyConditionRepository->update($condition, $data->toArray()); - $this->surveyRepository->touch((int) $survey->id); - - return; - } - - $this->surveyConditionRepository->create((int) $survey->id, $data->toArray()); - $this->surveyRepository->touch((int) $survey->id); - } - public function deleteCondition(SurveyModel $survey, int $conditionId): void { $this->assertUnlocked($survey);