I don't know if getAttributeSafe would be any different from
getAttribute.

The question with getAttributeSafe and parameterSafe is how do you set
default values?  For example you can do $request->getParameter
('foobar','hello') it says if the parameter isn't set(is null) then
default to 'hello'.  With getAttributeSafe what would it return if the
attribute is not safe?  false?  What if your parameter was false?
Null? Same problem as above, if you set the paramter to null.  Do you
understand the problem here?

I think the best solution for this is the hasAttribute followed by a
getAttribute if it is true and you are worried about null
properties.
Daum

On Nov 25, 10:49 am, Michal G <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I'm little concerned with getAttribute usage - because it returns
> default null value when attribute name is wrong.
>
> For example, using in template:
> echo $sf_user->getAttribute("last_login");
>
> instead of
> echo $sf_user->getAttribute("lastlogin");
>
> can lead to error which isn't noticed by php.
>
> My question is - do i worry to much or should i use class properties
> ($sf_user->lastLogin) / methods ($sf_user->getLastLogin()) instead of
> attributes?
>
> Same problem exist with getParameter - for example in actions -
> getting parameters from request, but this error is probably easier to
> catch by programmer.
>
> Maybe it would be nice to write getAttributeSafe() and
> getParameterSafe
> () methods which would throw exception when attribute/parameter is not
> found?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-devs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to