Code Duplication    Length = 17-18 lines in 3 locations

Controller/EmailController.php 3 locations

@@ 73-90 (lines=18) @@
70
     * @Route("/{id}/retry", name="email-spool_retry")
71
     * @Method("GET")
72
     */
73
    public function retryAction($id)
74
    {
75
        $em = $this->getDoctrine()->getManager();
76
77
        $entity = $em->getRepository('CitraxDatabaseSwiftMailerBundle:Email')->find($id);
78
79
        if (!$entity) {
80
            throw $this->createNotFoundException('Unable to find Email entity.');
81
        }
82
83
        $entity->setStatus(Email::STATUS_FAILED);
84
        $entity->setRetries(0);
85
86
        $em->persist($entity);
87
        $em->flush();
88
89
        return $this->redirect($this->generateUrl('email-spool'));
90
    }
91
92
    /**
93
     * Resend an email
@@ 98-115 (lines=18) @@
95
     * @Route("/{id}/resend", name="email-spool_resend")
96
     * @Method("GET")
97
     */
98
    public function resendAction($id)
99
    {
100
        $em = $this->getDoctrine()->getManager();
101
102
        $entity = $em->getRepository('CitraxDatabaseSwiftMailerBundle:Email')->find($id);
103
104
        if (!$entity) {
105
            throw $this->createNotFoundException('Unable to find Email entity.');
106
        }
107
108
        $entity->setStatus(Email::STATUS_READY);
109
        $entity->setRetries(0);
110
111
        $em->persist($entity);
112
        $em->flush();
113
114
        return $this->redirect($this->generateUrl('email-spool'));
115
    }
116
117
    /**
118
     * Cancel an email sending
@@ 123-139 (lines=17) @@
120
     * @Route("/{id}/cancel", name="email-spool_cancel")
121
     * @Method("GET")
122
     */
123
    public function cancelAction($id)
124
    {
125
        $em = $this->getDoctrine()->getManager();
126
127
        $entity = $em->getRepository('CitraxDatabaseSwiftMailerBundle:Email')->find($id);
128
129
        if (!$entity) {
130
            throw $this->createNotFoundException('Unable to find Email entity.');
131
        }
132
133
        $entity->setStatus(Email::STATUS_CANCELLED);
134
135
        $em->persist($entity);
136
        $em->flush();
137
138
        return $this->redirect($this->generateUrl('email-spool'));
139
    }
140
141
    /**
142
     * Deletes a Email entity.