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