getArray and testArray?

6 views
Skip to first unread message

Ben

unread,
Feb 19, 2008, 9:37:53 PM2/19/08
to inspekt
Hi there,

Any plans to implement getArray and testArray? Or is there a
particular reason they're not there?

Cheers,

- Ben

Ed Finkler

unread,
Feb 19, 2008, 10:17:00 PM2/19/08
to ins...@googlegroups.com
On Feb 19, 2008 9:37 PM, Ben <ben.v...@gmail.com> wrote:
>
> Hi there,
>
> Any plans to implement getArray and testArray? Or is there a
> particular reason they're not there?

If I follow what you mean...

Right now, all the get*() functions will return an array if the passed
key's value is an array.

The test*() functions don't support that *yet*.

--
Ed Finkler
http://funkatron.com
AIM: funka7ron
ICQ: 3922133
Skype: funka7ron

Ben Vinegar

unread,
Feb 19, 2008, 10:57:43 PM2/19/08
to inspekt
What about having getArray return a new Cage object, initialized to
that array?

- Ben

On Feb 19, 10:17 pm, "Ed Finkler" <funkat...@gmail.com> wrote:

Ed Finkler

unread,
Feb 19, 2008, 11:13:31 PM2/19/08
to ins...@googlegroups.com
It's possible. can you give me a use case?

--
Ed Finkler
http://funkatron.com
AIM: funka7ron
ICQ: 3922133
Skype: funka7ron

Ben Vinegar

unread,
Feb 19, 2008, 11:28:55 PM2/19/08
to inspekt
I guess I'm thinking of where I want to test values of a nested object
(i.e. name="user[name]") and don't want to use the array path notation
for 10+ attributes. Say, something like:

$user = $cage->getArray('user');
if ($user->testAlpha('name')) {
...
}

My apologies if this is in the docs and I've missed it.

- Ben

On Feb 19, 11:13 pm, "Ed Finkler" <funkat...@gmail.com> wrote:
> It's possible. can you give me a use case?
>
> --
> Ed Finklerhttp://funkatron.com
> AIM: funka7ron
> ICQ: 3922133
> Skype: funka7ron
>

Ed Finkler

unread,
Feb 20, 2008, 10:14:11 AM2/20/08
to ins...@googlegroups.com
Well, you could do that with a two-step process now:

$user = $cage->getRaw('user');
$user_cage = Inspekt_Cage::Factory($user);

or as a one-liner

$user_cage = Inspekt_Cage::Factory($cage->getRaw('user'));

Not that I'd encourage using the getRaw method too often. I can see
the appeal, and will look into adding it. Or, if you want to submit a
patch, go for it!

--
Ed Finkler


http://funkatron.com
AIM: funka7ron
ICQ: 3922133
Skype: funka7ron

janp...@gmail.com

unread,
Apr 9, 2008, 5:39:23 AM4/9/08
to inspekt
I have started to use this class, but unfortunately I have run into a
problem.

I have a rather large form that posts a lot of input fields (along
with values of course).
Today I insert those value into a DB with a foreach():

foreach ($_POST AS $field => $value) {
...
}

I can't see how I should do this with Inspekt without having some way
of returning the keys from the posted fields.
I am thinking of either:

$superCage = Inspekt::makeSuperCage();
foreach ($superCage->post->testArray() AS $key => $value) {
...
}

or

$superCage = Inspekt::makeSuperCage();
$arrKeys = $superCage->post->testKeys();
foreach ($arrKeys AS $key) {
$value = $superCage->post->getRaw($key);
...
}

Does that make any sense?

I can't see how I can iterate over all the posted fields/values anyway
with the currently available functions/methods.


On Feb 20, 6:13 am, "Ed Finkler" <funkat...@gmail.com> wrote:
> It's possible. can you give me a use case?
>
> --
> Ed Finklerhttp://funkatron.com
> AIM: funka7ron
> ICQ: 3922133
> Skype: funka7ron
>
Reply all
Reply to author
Forward
0 new messages