Code Duplication    Length = 24-24 lines in 2 locations

Admin/Admin.php 2 locations

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