Remove dead condition-editing code

The frontend condition create/edit path was never wired (no caller, no UI).
Conditions stay live where used: the SurveyFlowService reads tl_survey_condition
for jumps, the editor shows the read-only overview, and delete still works.

Removed:
- SurveyConditionEditorType (zero references)
- SurveyEditorService::saveCondition() + its SurveyConditionData import
- SurveyConditionData form model
- SurveyConditionRepository::update() (only caller was saveCondition)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jürgen Mummert
2026-06-14 13:23:11 +02:00
parent db7094fd1e
commit d6227d9f4e
4 changed files with 0 additions and 117 deletions
-36
View File
@@ -1,36 +0,0 @@
<?php
declare(strict_types=1);
namespace Mummert\SurveyBundle\Form\Model;
use Mummert\SurveyBundle\Model\SurveyConditionModel;
final class SurveyConditionData
{
public int $sourceQuestion = 0;
public string $answerValue = '';
public int $targetQuestion = 0;
public static function fromModel(SurveyConditionModel $condition): self
{
$data = new self();
$data->sourceQuestion = (int) $condition->sourceQuestion;
$data->answerValue = (string) $condition->answerValue;
$data->targetQuestion = (int) $condition->targetQuestion;
return $data;
}
/**
* @return array<string, mixed>
*/
public function toArray(): array
{
return [
'sourceQuestion' => $this->sourceQuestion,
'answerValue' => $this->answerValue,
'targetQuestion' => $this->targetQuestion,
];
}
}
-48
View File
@@ -1,48 +0,0 @@
<?php
declare(strict_types=1);
namespace Mummert\SurveyBundle\Form;
use Mummert\SurveyBundle\Form\Model\SurveyConditionData;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
final class SurveyConditionEditorType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$questionChoices = $options['question_choices'];
$builder
->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' => [],
]);
}
}
@@ -72,17 +72,6 @@ final class SurveyConditionRepository
return $this->findById($id) ?? throw new \RuntimeException('Bedingung konnte nicht angelegt werden.'); 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 public function delete(int $surveyId, int $conditionId): void
{ {
$this->connection->delete('tl_survey_condition', [ $this->connection->delete('tl_survey_condition', [
-22
View File
@@ -5,7 +5,6 @@ declare(strict_types=1);
namespace Mummert\SurveyBundle\Service; namespace Mummert\SurveyBundle\Service;
use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection;
use Mummert\SurveyBundle\Form\Model\SurveyConditionData;
use Mummert\SurveyBundle\Form\Model\SurveyEditorData; use Mummert\SurveyBundle\Form\Model\SurveyEditorData;
use Mummert\SurveyBundle\Form\Model\SurveyQuestionData; use Mummert\SurveyBundle\Form\Model\SurveyQuestionData;
use Mummert\SurveyBundle\Model\SurveyContentModel; 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 public function deleteCondition(SurveyModel $survey, int $conditionId): void
{ {
$this->assertUnlocked($survey); $this->assertUnlocked($survey);