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 cachesController_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

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