| @@ 29-46 (lines=18) @@ | ||
| 26 | $id = null |
|
| 27 | ) { |
|
| 28 | ||
| 29 | if (! is_null($id)) { |
|
| 30 | $item = $model->getRepository()->find($id); |
|
| 31 | if (is_null($item) || ! $model->isEditable($item)) { |
|
| 32 | return new JsonResponse([ |
|
| 33 | 'message' => trans('lang.message.access_denied'), |
|
| 34 | ], 403); |
|
| 35 | } |
|
| 36 | ||
| 37 | $form = $model->fireEdit($id); |
|
| 38 | } else { |
|
| 39 | if (! $model->isCreatable()) { |
|
| 40 | return new JsonResponse([ |
|
| 41 | 'message' => trans('lang.message.access_denied'), |
|
| 42 | ], 403); |
|
| 43 | } |
|
| 44 | ||
| 45 | $form = $model->fireCreate(); |
|
| 46 | } |
|
| 47 | ||
| 48 | if (is_null($element = $form->getElement($field))) { |
|
| 49 | return new JsonResponse([ |
|
| @@ 36-53 (lines=18) @@ | ||
| 33 | $field, |
|
| 34 | $id = null |
|
| 35 | ) { |
|
| 36 | if (! is_null($id)) { |
|
| 37 | $item = $model->getRepository()->find($id); |
|
| 38 | if (is_null($item) || ! $model->isEditable($item)) { |
|
| 39 | return new JsonResponse([ |
|
| 40 | 'message' => trans('lang.message.access_denied'), |
|
| 41 | ], 403); |
|
| 42 | } |
|
| 43 | ||
| 44 | $form = $model->fireEdit($id); |
|
| 45 | } else { |
|
| 46 | if (! $model->isCreatable()) { |
|
| 47 | return new JsonResponse([ |
|
| 48 | 'message' => trans('lang.message.access_denied'), |
|
| 49 | ], 403); |
|
| 50 | } |
|
| 51 | ||
| 52 | $form = $model->fireCreate(); |
|
| 53 | } |
|
| 54 | ||
| 55 | $messages = []; |
|
| 56 | $labels = []; |
|