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