Code Duplication    Length = 15-16 lines in 5 locations

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

@@ 100-114 (lines=15) @@
97
     *      views = { "default" }
98
     * )
99
     */
100
    public function getAction(Request $request)
101
    {
102
        $manager = $this->get("starkerxp_campaign.manager.campaign");
103
        try {
104
            $options = $this->resolveParams()->resolve($request->query->all());
105
            if (!$entite = $manager->findOneBy(['id' => $request->get('campaign_id')])) {
106
                return new JsonResponse(["payload" => $this->translate("entity.not_found", "campaign")], 404);
107
            }
108
        } catch (\Exception $e) {
109
            return new JsonResponse(["payload" => $e->getMessage()], 400);
110
        }
111
        $retour = $manager->toArray($entite, $this->getFields($options['fields']));
112
113
        return new JsonResponse($retour);
114
    }
115
116
    /**
117
     * @ApiDoc(

src/Starkerxp/UserBundle/Controller/UserController.php 1 location

@@ 102-117 (lines=16) @@
99
     *      views = { "default" }
100
     * )
101
     */
102
    public function getAction(Request $request)
103
    {
104
        $manager = $this->get("starkerxp_user.manager.user");
105
        try {
106
            $options = $this->resolveParams()->resolve($request->query->all());
107
            $user = $manager->findOneBy(['id' => $request->get('user_id')]);
108
        } catch (\Exception $e) {
109
            return new JsonResponse(["payload" => $e->getMessage()], 400);
110
        }
111
        if (!$user instanceof User) {
112
            return new JsonResponse(["payload" => $this->translate("user.entity.not_found", "user")], 404);
113
        }
114
        $retour = $manager->toArray($user, $this->getFields($options['fields']));
115
116
        return new JsonResponse($retour);
117
    }
118
119
    /**
120
     * @ApiDoc(

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

@@ 108-123 (lines=16) @@
105
     *      views = { "default" }
106
     * )
107
     */
108
    public function getAction(Request $request)
109
    {
110
        $manager = $this->get("starkerxp_campaign.manager.event");
111
        try {
112
            $options = $this->resolveParams()->resolve($request->query->all());
113
            $event = $manager->findOneBy(['id' => $request->get('id')]);
114
        } catch (\Exception $e) {
115
            return new JsonResponse(["payload" => $e->getMessage()], 400);
116
        }
117
        if (!$event instanceof Event) {
118
            return new JsonResponse(["payload" => $this->translate("entity.not_found", "event")], 404);
119
        }
120
        $retour = $manager->toArray($event, $this->getFields($options['fields']));
121
122
        return new JsonResponse($retour);
123
    }
124
125
    /**
126
     * @ApiDoc(

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

@@ 105-120 (lines=16) @@
102
     *      views = { "default" }
103
     * )
104
     */
105
    public function getAction(Request $request)
106
    {
107
        $manager = $this->get("starkerxp_campaign.manager.template");
108
        try {
109
            $options = $this->resolveParams()->resolve($request->query->all());
110
            if (!$entite = $manager->findOneBy(['id' => $request->get('template_id')])) {
111
                return new JsonResponse(["payload" => $this->translate("entity.not_found", "template")], 404);
112
            }
113
        } catch (\Exception $e) {
114
            return new JsonResponse(["payload" => $e->getMessage()], 400);
115
        }
116
117
        $retour = $manager->toArray($entite, $this->getFields($options['fields']));
118
119
        return new JsonResponse($retour);
120
    }
121
122
    /**
123
     * @ApiDoc(

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

@@ 105-120 (lines=16) @@
102
     *      views = { "default" }
103
     * )
104
     */
105
    public function getAction(Request $request)
106
    {
107
        $manager = $this->get("starkerxp_lead.manager.lead");
108
        try {
109
            $options = $this->resolveParams()->resolve($request->query->all());
110
            /** @var Lead $entite */
111
            if (!$entite = $manager->findOneBy(['id' => $request->get('lead_id')])) {
112
                return new JsonResponse(["payload" => $this->translate("entity.not_found", "lead")], 404);
113
            }
114
        } catch (\Exception $e) {
115
            return new JsonResponse(["payload" => $e->getMessage()], 400);
116
        }
117
118
        $retour = $manager->toArray($entite, $this->getFields($options['fields']));
119
120
        return new JsonResponse($retour);
121
    }
122
123
    /**