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/CampaignBundle/Controller/EventController.php 1 location

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

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

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

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

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