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