@@ 492-503 (lines=12) @@ | ||
489 | * @param Model $model |
|
490 | * @return Model |
|
491 | */ |
|
492 | private function doCommitCreate(Model $model) |
|
493 | { |
|
494 | $this->dispatchLifecycleEvent(Events::preCreate, $model); |
|
495 | ||
496 | $this->getPersisterFor($model->getType())->create($model); |
|
497 | $model->getState()->setNew(false); |
|
498 | // Should the model always reload? Or should the commit be assumed correct and just clear the new/dirty state? |
|
499 | $model->reload(); |
|
500 | ||
501 | $this->dispatchLifecycleEvent(Events::postCreate, $model); |
|
502 | return $model; |
|
503 | } |
|
504 | ||
505 | /** |
|
506 | * Performs a Model delete commit and persists to the database. |
|
@@ 511-520 (lines=10) @@ | ||
508 | * @param Model $model |
|
509 | * @return Model |
|
510 | */ |
|
511 | private function doCommitDelete(Model $model) |
|
512 | { |
|
513 | $this->dispatchLifecycleEvent(Events::preDelete, $model); |
|
514 | ||
515 | $this->getPersisterFor($model->getType())->delete($model); |
|
516 | $model->getState()->setDeleted(); |
|
517 | ||
518 | $this->dispatchLifecycleEvent(Events::postDelete, $model); |
|
519 | return $model; |
|
520 | } |
|
521 | ||
522 | /** |
|
523 | * Performs a Model update commit and persists to the database. |
|
@@ 528-538 (lines=11) @@ | ||
525 | * @param Model $model |
|
526 | * @return Model |
|
527 | */ |
|
528 | private function doCommitUpdate(Model $model) |
|
529 | { |
|
530 | $this->dispatchLifecycleEvent(Events::preUpdate, $model); |
|
531 | ||
532 | $this->getPersisterFor($model->getType())->update($model); |
|
533 | // Should the model always reload? Or should the commit be assumed correct and just clear the new/dirty state? |
|
534 | $model->reload(); |
|
535 | ||
536 | $this->dispatchLifecycleEvent(Events::postUpdate, $model); |
|
537 | return $model; |
|
538 | } |
|
539 | ||
540 | /** |
|
541 | * Validates that an embed name/type can be set to an owning embed metadata type. |