문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top