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