Code Duplication    Length = 24-24 lines in 2 locations

Admin/Admin.php 2 locations

@@ 169-192 (lines=24) @@
166
     *
167
     * @return bool true if the entity was saved without errors
168
     */
169
    public function save()
170
    {
171
        try {
172
            foreach ($this->entities as $entity) {
173
                $this
174
                    ->dataProvider
175
                    ->save($entity);
176
            }
177
            // inform user everything went fine
178
            $this
179
                ->messageHandler
180
                ->handleSuccess('lag.admin.' . $this->name . '.saved');
181
            $success = true;
182
        } catch (Exception $e) {
183
            $this
184
                ->messageHandler
185
                ->handleError(
186
                    'lag.admin.saved_errors',
187
                    "An error has occurred while saving an entity : {$e->getMessage()}, stackTrace: {$e->getTraceAsString()}"
188
                );
189
            $success = false;
190
        }
191
        return $success;
192
    }
193
194
    /**
195
     * Remove an entity with data provider
@@ 199-222 (lines=24) @@
196
     *
197
     * @return bool true if the entity was saved without errors
198
     */
199
    public function remove()
200
    {
201
        try {
202
            foreach ($this->entities as $entity) {
203
                $this
204
                    ->dataProvider
205
                    ->remove($entity);
206
            }
207
            // inform user everything went fine
208
            $this
209
                ->messageHandler
210
                ->handleSuccess('lag.admin.' . $this->name . '.deleted');
211
            $success = true;
212
        } catch (Exception $e) {
213
            $this
214
                ->messageHandler
215
                ->handleError(
216
                    'lag.admin.deleted_errors',
217
                    "An error has occurred while deleting an entity : {$e->getMessage()}, stackTrace: {$e->getTraceAsString()} "
218
                );
219
            $success = false;
220
        }
221
        return $success;
222
    }
223
224
    /**
225
     * Generate a route for admin and action name (like lag.admin.my_admin)