Code Duplication    Length = 23-28 lines in 2 locations

Apps/Controller/Admin/Content.php 1 location

@@ 81-108 (lines=28) @@
78
     * @throws \Ffcms\Core\Exception\SyntaxException
79
     * @throws \Ffcms\Core\Exception\NativeException
80
     */
81
    public function actionUpdate($id)
82
    {
83
        // get item with trashed objects
84
        $record = ContentEntity::withTrashed()->find($id);
85
        $isNew = $record->id === null;
86
87
        // create empty object if its new
88
        if ($isNew === true) {
89
            $record = new ContentEntity();
90
        }
91
92
        // init model
93
        $model = new FormContentUpdate($record);
94
95
        // check if model is submit
96
        if ($model->send() && $model->validate()) {
97
            $model->save();
98
            if ($isNew === true) {
99
                App::$Response->redirect('content/index');
100
            }
101
            App::$Session->getFlashBag()->add('success', __('Content is successful updated'));
102
        }
103
104
        // draw response
105
        return App::$View->render('content_update', [
106
            'model' => $model
107
        ]);
108
    }
109
110
    /**
111
     * Delete content by id

Apps/Controller/Admin/Profile.php 1 location

@@ 122-144 (lines=23) @@
119
     * @param $id
120
     * @return string
121
     */
122
    public function actionFieldupdate($id)
123
    {
124
        // get current record or new and init form DI
125
        $record = ProfileField::findOrNew($id);
126
        $model = new FormFieldUpdate($record);
127
128
        $isNew = false;
129
        if ($record->id === null) {
130
            $isNew = true;
131
        }
132
        // check if form is submited
133
        if ($model->send() && $model->validate()) {
134
            $model->save();
135
            if (true === $isNew) {
136
                App::$Response->redirect('profile/fieldlist');
137
            }
138
            App::$Session->getFlashBag()->add('success', __('Profile field was successful updated'));
139
        }
140
141
        return App::$View->render('field_update', [
142
            'model' => $model->export()
143
        ]);
144
    }
145
146
    /**
147
     * Delete custom field action