More GET variables?

21 views
Skip to first unread message

Chris Boden

unread,
Apr 4, 2011, 1:15:45 PM4/4/11
to Alloy
How would I get additional parameters in a Controller Action call's
Request object from standard GET parameters?

// Inside /app/config/routes.php
$router->route('someroute', '/route/match(.<:format>)')->defaults(/*
etc */);

// User requests:
http://localhost/route/match.html?hello=world

// inside Controller:
print_r($request);

// Expected Result:
Alloy\Request Object
(
[_params:protected] => Array
(
[format] => html
[module] => Abra
[action] => Cadabra
[route] => someroute
[hello] => world /* desired, but missing */
)
)

Vance Lucas

unread,
Apr 4, 2011, 2:12:10 PM4/4/11
to allo...@googlegroups.com
You access them the same way as others. The stored params on the request object are only the ones that have been explicitly set, like those matched from the router. Others are retrieved on demand from the $_GET and $_POST superglobals.

$hello = $request->hello;
$hello = $request->get('hello', 'value if not present');
$hello = $request->post('hello'); // looks only in $_POST variables

--
Vance Lucas
http://vancelucas.com

Chris Boden

unread,
Apr 4, 2011, 2:14:31 PM4/4/11
to Alloy
Oh my...what a silly oversight...I just dumped the Request, didn't see
it, and came here during that brain fart. Sorry for wasting your
time.

On Apr 4, 2:12 pm, Vance Lucas <va...@vancelucas.com> wrote:
> You access them the same way as others. The stored params on the request
> object are only the ones that have been explicitly set, like those matched
> from the router. Others are retrieved on demand from the $_GET and $_POST
> superglobals.
>
> $hello = $request->hello;
> $hello = $request->get('hello', 'value if not present');
> $hello = $request->post('hello'); // looks only in $_POST variables
>
> --
> Vance Lucashttp://vancelucas.com
Reply all
Reply to author
Forward
0 new messages