Completed
Push — master ( 3560db...6e658b )
by
unknown
08:14
created

ContactEmailController::getForm()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace OroCRM\Bundle\ContactBundle\Controller\Api\Rest;
4
5
use Symfony\Component\HttpFoundation\JsonResponse;
6
use Symfony\Component\HttpFoundation\Response;
7
8
use FOS\RestBundle\Controller\Annotations\NamePrefix;
9
use FOS\RestBundle\Controller\Annotations\RouteResource;
10
use FOS\RestBundle\Routing\ClassResourceInterface;
11
use FOS\RestBundle\Controller\Annotations as Rest;
12
13
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
14
15
use Oro\Bundle\SecurityBundle\Annotation\Acl;
16
use Oro\Bundle\FormBundle\Form\Handler\ApiFormHandler;
17
use Oro\Bundle\SoapBundle\Controller\Api\Rest\RestController;
18
19
/**
20
 * @RouteResource("email")
21
 * @NamePrefix("oro_api_")
22
 */
23
class ContactEmailController extends RestController implements ClassResourceInterface
24
{
25
    /**
26
     * Create entity ContactEmail
27
     * oro_api_post_contact_email
28
     **
29
     * @return Response
30
     *
31
     * @ApiDoc(
32
     *      description="Create entity",
33
     *      resource=true,
34
     *      requirements = {
35
     *          {"name"="id", "dataType"="integer"},
36
     *      }
37
     * )
38
     */
39
    public function postAction()
40
    {
41
        $response = $this->handleCreateRequest();
42
43
        return $response;
44
    }
45
46
    /**
47
     * Delete entity ContactEmail
48
     * oro_api_delete_contact_email
49
     *
50
     * @param int $id
51
     *
52
     * @ApiDoc(
53
     *      description="Delete ContactEmail"
54
     * )
55
     *
56
     * @return Response
57
     */
58 View Code Duplication
    public function deleteAction($id)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
59
    {
60
        try {
61
            $this->getDeleteHandler()->handleDelete($id, $this->getManager());
62
63
            return new JsonResponse(["id" => ""]);
64
        } catch (\Exception $e) {
65
            return new JsonResponse(["code" => $e->getCode(), "message" => $e->getMessage()], $e->getCode());
66
        }
67
    }
68
69
    /**
70
     * {@inheritdoc}
71
     */
72
    public function getManager()
73
    {
74
        return $this->get('orocrm_contact.contact_email.manager.api');
75
    }
76
77
    /**
78
     * @return ApiFormHandler
79
     */
80
    public function getFormHandler()
81
    {
82
        return $this->get('orocrm_contact.form.type.contact_email.handler');
83
    }
84
85
    /**
86
     * {@inheritdoc}
87
     */
88
    public function getForm()
89
    {
90
        return $this->get('orocrm_contact.form.type.contact_email.type');
91
    }
92
93
    /**
94
     * {@inheritdoc}
95
     */
96
    public function getDeleteHandler()
97
    {
98
        return $this->get('orocrm_contact.form.type.contact_email.handler');
99
    }
100
}
101