| 1 | <?php |
||
| 18 | abstract class CreateRecord extends Action |
||
| 19 | { |
||
| 20 | use SaveRecordTrait; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @var array |
||
| 24 | */ |
||
| 25 | public $validBodyParams = []; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @inheritdoc |
||
| 29 | */ |
||
| 30 | public $statusCodeSuccess = 201; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @param array $config |
||
| 34 | * @return ActiveRecord |
||
| 35 | */ |
||
| 36 | abstract protected function newRecord(array $config = []): ActiveRecord; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Body params that should be set on the record. |
||
| 40 | * |
||
| 41 | * @return array |
||
| 42 | */ |
||
| 43 | protected function validBodyParams(): array |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @param ActiveRecord $record |
||
| 50 | * @return ActiveRecord |
||
| 51 | */ |
||
| 52 | protected function populate(ActiveRecord $record): ActiveRecord |
||
| 60 | |||
| 61 | /** |
||
| 62 | * @return ActiveRecord |
||
| 63 | * @throws \yii\web\HttpException |
||
| 64 | */ |
||
| 65 | public function run() |
||
| 71 | |||
| 72 | /** |
||
| 73 | * @inheritdoc |
||
| 74 | * @param ActiveRecord $record |
||
| 75 | */ |
||
| 76 | protected function performAction(ActiveRecord $record): bool |
||
| 80 | } |
||
| 81 |