Code Duplication    Length = 22-34 lines in 2 locations

htdocs_symfony/src/Controller/Backend/CachesController.php 1 location

@@ 45-78 (lines=34) @@
42
     *
43
     * @return Response
44
     */
45
    public function index(Request $request)
46
    : Response {
47
        $fetchedCaches = '';
48
49
        // create input field for caches_by_searchfield
50
        $form = $this->createForm(CachesFormType::class);
51
52
        // see: https://symfonycasts.com/screencast/symfony-forms/form-submit
53
        // handles the request (submit-button of the form), but only if there is a POST request
54
        $form->handleRequest($request);
55
        // if is true only if there is a request submitted and it is valid
56
        if ($form->isSubmitted() && $form->isValid()) {
57
            // read content of form input field
58
            $inputData = $form->getData();
59
60
            // send request to DB
61
            $fetchedCaches = $this->getCachesForSearchField($inputData['content_caches_searchfield']);
62
        }
63
64
        if ($fetchedCaches === '') {
65
            return $this->render(
66
                'backend/caches/index.html.twig', [
67
                                                    'cachesForm' => $form->createView(),
68
                                                ]
69
            );
70
        } else {
71
            return $this->render(
72
                'backend/caches/basicview.html.twig', [
73
                                                        'cachesForm' => $form->createView(),
74
                                                        'caches_by_searchfield' => $fetchedCaches
75
                                                    ]
76
            );
77
        }
78
    }
79
80
    /**
81
     * @param string $wpID

htdocs_symfony/src/Controller/Backend/CoordinatesController.php 1 location

@@ 39-60 (lines=22) @@
36
     *
37
     * @return Response
38
     */
39
    public function index(Request $request)
40
    : Response {
41
        $fetchedCoordinates = '';
42
        $form = $this->createForm(CoordinatesFormType::class);
43
44
        $form->handleRequest($request);
45
        if ($form->isSubmitted() && $form->isValid()) {
46
            $inputData = $form->getData();
47
48
            $fetchedCoordinates = $this->getCoordinatesForSearchField($inputData['content_coordinates_searchfield']);
49
        }
50
51
        if ($fetchedCoordinates === '') {
52
            return $this->render(
53
                'backend/coordinates/index.html.twig', ['coordinatesForm' => $form->createView()]
54
            );
55
        } else {
56
            return $this->render(
57
                'backend/coordinates/index.html.twig', ['coordinatesForm' => $form->createView(), 'coordinates_by_searchfield' => $fetchedCoordinates]
58
            );
59
        }
60
    }
61
62
    /**
63
     * @param string $lat