Code Duplication    Length = 22-24 lines in 3 locations

src/Webcook/Cms/CoreBundle/Controller/MenuContentProviderSettingsController.php 1 location

@@ 104-127 (lines=24) @@
101
     * )
102
     * @Put("/content-providers/menu/settings/{id}", options={"i18n"=false})
103
     */
104
    public function putMenuContentProviderSettingsAction($id)
105
    {
106
        $this->checkPermission(WebcookCmsVoter::ACTION_EDIT);
107
108
        try {
109
            $settings = $this->getSettingsById($id, $this->getLockVersion((string) new MenuContentProviderSettings()));
110
        } catch (NotFoundHttpException $e) {
111
            $settings = new MenuContentProviderSettings();
112
        }
113
114
        $response = $this->processSettingsForm($settings, 'PUT');
115
116
        if ($response instanceof MenuContentProviderSettings) {
117
            $statusCode = 204;
118
            $message = 'Settings has been updated.';
119
        } else {
120
            $statusCode = 400;
121
            $message = 'Error while updating settings.';
122
        }
123
124
        $view = $this->getViewWithMessage($response, $statusCode, $message);
125
126
        return $this->handleView($view);
127
    }
128
129
    /**
130
     * Delete settings.

src/Webcook/Cms/CoreBundle/Tests/Helpers/Controller/TestController.php 1 location

@@ 56-77 (lines=22) @@
53
        return $this->handleView($view);
54
    }
55
56
    public function putTestsAction($id)
57
    {
58
        try {
59
            $testEntity = $this->getTestEntityById($id, $this->getLockVersion((string) new TestEntity()));
60
        } catch (NotFoundHttpException $e) {
61
            $testEntity = new TestEntity();
62
        }
63
64
        $response = $this->processTestForm($testEntity, 'PUT');
65
66
        if ($response instanceof TestEntity) {
67
            $statusCode = 204;
68
            $message = 'Test entity has been updated.';
69
        } else {
70
            $statusCode = 400;
71
            $message = 'Error while updating test entity.';
72
        }
73
74
        $view = $this->getViewWithMessage($response, $statusCode, $message);
75
76
        return $this->handleView($view);
77
    }
78
79
    /**
80
     * @param TestEntity $test

src/Webcook/Cms/CoreBundle/Controller/PageController.php 1 location

@@ 113-136 (lines=24) @@
110
     * )
111
     * @Put(options={"i18n"=false})
112
     */
113
    public function putPageAction($id)
114
    {
115
        $this->checkPermission(WebcookCmsVoter::ACTION_EDIT);
116
117
        try {
118
            $page = $this->getPageById($id, $this->getLockVersion((string) new Page()));
119
        } catch (NotFoundHttpException $e) {
120
            $page = new Page();
121
        }
122
123
        $response = $this->processPageForm($page, 'PUT');
124
125
        if ($response instanceof Page) {
126
            $statusCode = 204;
127
            $message = 'Page has been updated.';
128
        } else {
129
            $statusCode = 400;
130
            $message = 'Error while updating Page.';
131
        }
132
133
        $view = $this->getViewWithMessage($response, $statusCode, $message);
134
135
        return $this->handleView($view);
136
    }
137
138
    /**
139
     * Update Page.