G
G
Grigory Vasilkov2017-01-07 00:11:19
PHP
Grigory Vasilkov, 2017-01-07 00:11:19

How to properly ensure the interaction of the model-controller?

If there is an error in the model, I return
$this
->request
->http_code(403)
->error(1, $message)
->html();
This is true if I request a model from a controller that returns a layout page.
If I request the model via ajax request and there is an error, everything will fall down.
Accordingly, if I return ->json() - if I issue the layout - everything will fall again.
It is clear that you can write a crutch in request - if $type = "html", but how to do it correctly?
Does this mean that the model should always return an array() and all errors are handled only in the controllers?
Or is there a smarter way?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DevMan, 2017-01-07
@gzhegow

usually the request type is determined by the address and/or headers.
This is the answer to what is written in the comment.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question