G
G
grabbee2014-06-12 07:38:06
Design patterns
grabbee, 2014-06-12 07:38:06

MVC logic - where exactly to process GET parameters and how to pass them?

I understand OOP, in some ways it is difficult. For example, now it is not entirely clear where exactly to get GET data
1. There is a single entry point - index.php
2. bootstap.php - connects to - index.php
3. Router.php class - connects to - bootstap.php, as I I understand, the router is already part of the controller. The URI is parsed in it and, depending on the parameters, a specific controller is connected and the desired action is launched
4. The controller itself, there are many of them and they are different. For example, now you need to process an ajax request to search for the name of the city - contr_ajax.class.
5. The "cities" model is connected in the ajax request controller
-- All controllers of the contr_xxxxxx.class type have one ancestor \core\Controller.class - but I don't use it now
The question consists in "dependence" of classes on the global/external data. At first I received GET in the "ajax requests" class itself contr_ajax.class - in the desired action, while the class constructor is simple and without parameters __construct()
Now I began to doubt whether this is correct? Perhaps this should be done at a higher level, for example, in a router or a controller common to all (\core\Controller.class)? Help to understand please.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
vitaliycto, 2014-06-12
@vitaliycto

Better create an Input library that will secure the incoming data.
Well, of course, the initiation of obtaining a variable must be done in the controller.

class NewController extend Controller{
    function getMethod(){
        $q = Input::get('q');
        $arr = Input::post('a','b','c');
    }
}

V
Volodymyr Godyak, 2014-07-31
@wmgodyak

Learn codeigniter, it's very simple. And then spin the bike

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question