Storing a Model with an Input Filter in the AuthorizationService default Storage

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Storing a Model with an Input Filter in the AuthorizationService default Storage

Mat Howard
Hi All,

I'm experiencing an odd issue. I've gone through the Getting Started Guide
for ZF2 (http://framework.zend.com/manual/2.0/en/user-guide/overview.html)
so my code is based on this example. I also went through the Authentication
guide (
http://framework.zend.com/manual/2.0/en/modules/zend.authentication.intro.html
).

In the Authentication example, for DB Authentication, it demonstrates using
$auth->getStorage()->write() to save mixed data with the authorization
session. We can then later use $auth->getStorage()->read() to get that
mixed data.

I'm trying to use this method so I can save my User model with the Auth
session. I've setup my User model similar to the getting starting guide, so
I have an input filter which is not created until I call the getInputFilter
method of my model.

I'm calling getInputFilter from my model so I can assign it to the form
before validation. After validation and authentication, I call
$auth->getStorage()->write($user) to save the user object with the session.
As soon as I call $auth->getStorage()->read(), I get a PHP Fatal Error "PHP
Fatal error:  Exception thrown without a stack frame in Unknown on line 0,
referer: http://zf2-test.localcent.com/user".

If I comment the line that calls getInputFilter, everything works fine. Is
there a reason why I can't retrieve a model with an input filter from the
AuthenticationService's default Storage?

An easy way to solve it is to create a second User object and assign the
properties so I can use that in the Authentication session, but I dont see
why I should need to do that. Any insight is appreciated.

Thanks,
Mat