1

Right now, im using drupal for making a site. Im modifying the drupals user module, because i need to make a custom layout for the profile page.

Unfortenly im having issues for accessing trough the array.

all the data of the profile is on an array ($user_profile)

The array is just HUGE. im trying to navigate trough the objects.

While im doing a good job navigating (thanks to the print_r function), im facing a problem right now.

there's an object called entityInfo:protected. Inside this object there's more objects (by example, im trying to access to the object that is inside of this object, called label.

the issue is, if i try to do this:

echo $user_profile['profile_medico']['view']['profile2']['2']['field_tags']['#object']->{'entityInfo:protected'}->label 

I get the next message

Notice: Undefined property: Profile::$entityInfo:protected in include() (line 55 of D:\xampp\htdocs\specialdr\modules\user\user-profile.tpl.php). Notice: Trying to get property of non-object in include() (line 55 of D:\xampp\htdocs\specialdr\modules\user\user-profile.tpl.php).

I dont know how can i write this correctly so i can access to this object and keep going trough the arrays and objects... because i still have a loong way until i get to the objects i need to access.

By the way... if you want to see the array... http://fancomix.net/bigarray.txt

Thanks in advance.

kapa
  • 77,694
  • 21
  • 158
  • 175
EgEm
  • 13
  • 3

1 Answers1

0

It is simply ->entityInfo, :protected is not needed, it is an access modifier or visibility modifier. It is only displayed in the var_dump() to provide information about the property. An object property (and method also) can be declared either public, protected or private in PHP. You can read more about Visibility in the Manual.

protected means the property can only be accessed from an object method - no outside access, so you won't be able to get the property. The Profile class can have a getter method though - you should inspect the definition of that class to find it, or make necessary changes if you can, like changing it to public or writing a getter method.

kapa
  • 77,694
  • 21
  • 158
  • 175
  • HI, thanks for your quick answer and indeed that was the issue!. Now, unfortenly, when i try to load something inside from this object it gives me a fatal error. "Fatal error: Cannot access protected property Profile::$entityInfo in D:\xampp\htdocs\specialdr\modules\user\user-profile.tpl.php on line 57" Im sorry, im trying to understand with the link you gave me but i hope you could help me with this... Again... Thanks! – EgEm Sep 19 '12 at 17:29
  • @EgEm Well, yeah. Forgot to mention that a protected property cannot be read from outside the object, only object methods can access it. – kapa Sep 19 '12 at 19:21
  • Thank you so much!, i finally manage to understand my issue... and in the end, i verified and the Location of the info i needed wasnt inside of the EntityInfo Object... It was OUTSIDE! DAH DX... But hey, thank you, now i know something new, and i need to check more about "objects" and all that stuff. Thanks! – EgEm Sep 19 '12 at 20:40