Code Duplication    Length = 24-24 lines in 2 locations

Admin/Admin.php 2 locations

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