Code Duplication    Length = 19-22 lines in 4 locations

src/Starkerxp/LeadBundle/Controller/LeadController.php 1 location

@@ 56-76 (lines=21) @@
53
     * )
54
     *
55
     */
56
    public function cgetAction(Request $request)
57
    {
58
        $manager = $this->get("starkerxp_lead.manager.lead");
59
        try {
60
            $options = $this->resolveParams()->resolve($request->query->all());
61
            $orderBy = $this->getOrderBy($options['sort']);
62
            $resultSets = $manager->findBy([], $orderBy, $options['limit'], $options['offset']);
63
        } catch (\Exception $e) {
64
            return new JsonResponse(["payload" => $e->getMessage()], 400);
65
        }
66
        if (empty($resultSets)) {
67
            return new JsonResponse([]);
68
        }
69
        $retour = array_map(
70
            function ($element) use ($manager, $options) {
71
                return $manager->toArray($element, $this->getFields($options['fields']));
72
            },
73
            $resultSets
74
        );
75
76
        return new JsonResponse($retour);
77
    }
78
79

src/Starkerxp/CampaignBundle/Controller/CampaignController.php 1 location

@@ 55-73 (lines=19) @@
52
     *      views = { "default" }
53
     * )
54
     */
55
    public function cgetAction(Request $request)
56
    {
57
        $manager = $this->get("starkerxp_campaign.manager.campaign");
58
        try {
59
            $options = $this->resolveParams()->resolve($request->query->all());
60
            $orderBy = $this->getOrderBy($options['sort']);
61
            $resultSets = $manager->findBy([], $orderBy, $options['limit'], $options['offset']);
62
        } catch (\Exception $e) {
63
            return new JsonResponse(["payload" => $e->getMessage()], 400);
64
        }
65
        $retour = array_map(
66
            function ($element) use ($manager, $options) {
67
                return $manager->toArray($element, $this->getFields($options['fields']));
68
            },
69
            $resultSets
70
        );
71
72
        return new JsonResponse($retour);
73
    }
74
75
    /**
76
     * @ApiDoc(

src/Starkerxp/CampaignBundle/Controller/EventController.php 1 location

@@ 53-73 (lines=21) @@
50
     *      views = { "default" }
51
     * )
52
     */
53
    public function cgetAction(Request $request)
54
    {
55
        $manager = $this->get("starkerxp_campaign.manager.event");
56
        try {
57
            $options = $this->resolveParams()->resolve($request->query->all());
58
            $orderBy = $this->getOrderBy($options['sort']);
59
            $resultSets = $manager->findBy([], $orderBy, $options['limit'], $options['offset']);
60
        } catch (\Exception $e) {
61
            return new JsonResponse(["payload" => $e->getMessage()], 400);
62
        }
63
        if (empty($resultSets)) {
64
            return new JsonResponse([]);
65
        }
66
        $retour = array_map(
67
            function ($element) use ($manager, $options) {
68
                return $manager->toArray($element, $this->getFields($options['fields']));
69
            },
70
            $resultSets
71
        );
72
73
        return new JsonResponse($retour);
74
    }
75
76

src/Starkerxp/CampaignBundle/Controller/TemplateController.php 1 location

@@ 56-77 (lines=22) @@
53
     * )
54
     *
55
     */
56
    public function cgetAction(Request $request)
57
    {
58
        $manager = $this->get("starkerxp_campaign.manager.template");
59
        try {
60
            $options = $this->resolveParams()->resolve($request->query->all());
61
            $orderBy = $this->getOrderBy($options['sort']);
62
            $resultSets = $manager->findBy([], $orderBy, $options['limit'], $options['offset']);
63
        } catch (\Exception $e) {
64
            return new JsonResponse(["payload" => $e->getMessage()], 400);
65
        }
66
        if (empty($resultSets)) {
67
            return new JsonResponse([]);
68
        }
69
        $retour = array_map(
70
            function ($element) use ($manager, $options) {
71
                return $manager->toArray($element, $this->getFields($options['fields']));
72
            },
73
            $resultSets
74
        );
75
76
        return new JsonResponse($retour);
77
    }
78
79
80
    /**