Re: passing $_POST variables to classes
On Jul 30, 9:23 pm, "amygdala" <nore...@xxxxxxxxxxx> wrote:
Hi all,
I'm starting this new project in which I'ld like to implement sort of a
design pattern I have seen being used in the CodeIgniter framework.
Basically, the site will examine the URI and based on the segments of the
URI it will fire up some controller class, for instance, say I have an inbox
in which end-users can view messages they got from other users, they'ld
start at:
http://www.somesite.com/inbox/view/
This will then call upon the function view in the class inbox:
class Inbox extends Controller
{
// ...
public function view()
{
// ...
}
// ...
}
Any trailing segments of the URI will be passed as supplement arguments to
the function.
Now, if $_POST variables are sent to some page and are needed by the called
upon function in the appropriate class, would it be bad practice to simply
extract those $_POST variables from the superglobal $_POST inside this
function? Preferably I would like to send the $_POST variables as arguments
to the function, but I'm not sure how to implement this correctly, nor am I
even completely sure as to why this would be better practice, other than
that the function will only accept predefined arguments.
What are your views on implementing such a 'pattern' (if you will). Would
you even suggest such an implementation, or am I bound to get into trouble
with proposed pattern?
Thank you in advance.
The request registry might be a good way to abstract the request data
in your case. The registry will handle the data gathering from your
superglobals (and possibly other places if you wish) and provide a
central point to references the data, without having to pass the
variables around your API.
http://www.phppatterns.com/docs/design/the_registry
.
Relevant Pages
- Re: passing $_POST variables to classes
... This will then call upon the function view in the class inbox: ... if $_POST variables are sent to some page and are needed by the called ... What are your views on implementing such a 'pattern'. ... If however, you're writing an app that might get it's instructions another way, it might be handy to let a controller decide what kind of request it gets, and create a request object accordingly. ... (comp.lang.php) - Re: passing $_POST variables to classes
... I'm starting this new project in which I'ld like to implement sort of a design pattern I have seen being used in the CodeIgniter framework. ... Basically, the site will examine the URI and based on the segments of the URI it will fire up some controller class, for instance, say I have an inbox in which end-users can view messages they got from other users, they'ld start at: ... Now, if $_POST variables are sent to some page and are needed by the called upon function in the appropriate class, would it be bad practice to simply extract those $_POST variables from the superglobal $_POST inside this function? ... What I am a bit worried about though, is that when users accidentally, submit a larger URI, my functions will misinterpret the trailing URI segments, when in fact it should be using $_POST vars. ... (comp.lang.php) - Re: passing $_POST variables to classes
... I'm starting this new project in which I'ld like to implement sort of a design pattern I have seen being used in the CodeIgniter framework. ... Basically, the site will examine the URI and based on the segments of the URI it will fire up some controller class, for instance, say I have an inbox in which end-users can view messages they got from other users, they'ld start at: ... This will then call upon the function view in the class inbox: ... Now, if $_POST variables are sent to some page and are needed by the called upon function in the appropriate class, would it be bad practice to simply extract those $_POST variables from the superglobal $_POST inside this function? ... (comp.lang.php) - passing $_POST variables to classes
... URI it will fire up some controller class, for instance, say I have an inbox ... This will then call upon the function view in the class inbox: ... if $_POST variables are sent to some page and are needed by the called ... What are your views on implementing such a 'pattern'. ... (comp.lang.php) - Re: passing $_POST variables to classes
... if $_POST variables are sent to some page and are needed by the ... What are your views on implementing such a 'pattern'. ... controller decide what kind of request it gets, ... kind of response do I want' i just part of the request offcourse. ... (comp.lang.php) |
|