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