You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AbstractBuilder.php 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace domain\_;
  3. use yii\base\Model;
  4. use yii\db\ActiveRecord;
  5. abstract class AbstractBuilder extends AbstractService implements BuilderInterface
  6. {
  7. public function create(Model $model): bool
  8. {
  9. return $model->save();
  10. }
  11. public function update(Model $model): bool
  12. {
  13. return $model->save();
  14. }
  15. public function delete(Model $model): bool
  16. {
  17. return $model->delete();
  18. }
  19. /**
  20. * @deprecated
  21. */
  22. public function saveCreate(ActiveRecord $model): bool
  23. {
  24. return $model->save();
  25. }
  26. /**
  27. * @deprecated
  28. */
  29. public function saveUpdate(ActiveRecord $model): bool
  30. {
  31. return $model->save();
  32. }
  33. /**
  34. * Status
  35. */
  36. public function updateStatusOnline(Model $model)
  37. {
  38. $model->status = StatusInterface::STATUS_ONLINE;
  39. $this->update($model);
  40. }
  41. public function updateStatusOffline(Model $model)
  42. {
  43. $model->status = StatusInterface::STATUS_OFFLINE;
  44. $this->update($model);
  45. }
  46. public function updateStatusDeleted(Model $model)
  47. {
  48. $model->status = StatusInterface::STATUS_DELETED;
  49. $this->update($model);
  50. }
  51. }