Code Duplication    Length = 24-24 lines in 2 locations

Admin/Admin.php 2 locations

@@ 195-218 (lines=24) @@
192
     *
193
     * @return bool true if the entity was saved without errors
194
     */
195
    public function save()
196
    {
197
        try {
198
            foreach ($this->entities as $entity) {
199
                $this
200
                    ->dataProvider
201
                    ->save($entity);
202
            }
203
            // inform user everything went fine
204
            $this
205
                ->messageHandler
206
                ->handleSuccess('lag.admin.' . $this->name . '.saved');
207
            $success = true;
208
        } catch (Exception $e) {
209
            $this
210
                ->messageHandler
211
                ->handleError(
212
                    'lag.admin.saved_errors',
213
                    "An error has occurred while saving an entity : {$e->getMessage()}, stackTrace: {$e->getTraceAsString()}"
214
                );
215
            $success = false;
216
        }
217
        return $success;
218
    }
219
220
    /**
221
     * Remove an entity with data provider
@@ 225-248 (lines=24) @@
222
     *
223
     * @return bool true if the entity was saved without errors
224
     */
225
    public function remove()
226
    {
227
        try {
228
            foreach ($this->entities as $entity) {
229
                $this
230
                    ->dataProvider
231
                    ->remove($entity);
232
            }
233
            // inform user everything went fine
234
            $this
235
                ->messageHandler
236
                ->handleSuccess('lag.admin.' . $this->name . '.deleted');
237
            $success = true;
238
        } catch (Exception $e) {
239
            $this
240
                ->messageHandler
241
                ->handleError(
242
                    'lag.admin.deleted_errors',
243
                    "An error has occurred while deleting an entity : {$e->getMessage()}, stackTrace: {$e->getTraceAsString()} "
244
                );
245
            $success = false;
246
        }
247
        return $success;
248
    }
249
250
    /**
251
     * Generate a route for admin and action name (like lag.admin.my_admin)