Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Access value of nested object

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
vmbarmedilla
Smarty n00b


Joined: 11 Aug 2019
Posts: 2

PostPosted: Sun Aug 11, 2019 4:00 pm    Post subject: Access value of nested object Reply with quote

Here is my object, how can i access the CustomAttributes array, If some can help me on this one. I will really appreciate it. Thank you


Code:

ReservationSlot Object
(
    [_begin:protected] => Date Object
        (
            [date:Date:private] => DateTime Object
                (
                    [date] => 2019-08-11 08:00:00.000000
                    [timezone_type] => 3
                    [timezone] => America/New_York
                )

            [parts:Date:private] => Array
                (
                    [hours] => 08
                    [minutes] => 00
                    [seconds] => 00
                    [mon] => 08
                    [mday] => 11
                    [year] => 2019
                    [wday] => 0
                )

            [timezone:Date:private] => America/New_York
            [timestring:Date:private] => 2019-08-11 08:00:00
            [timestamp:Date:private] => 1565524800
        )

    [_end:protected] => Date Object
        (
            [date:Date:private] => DateTime Object
                (
                    [date] => 2019-08-11 08:30:00.000000
                    [timezone_type] => 3
                    [timezone] => America/New_York
                )

            [parts:Date:private] => Array
                (
                    [hours] => 08
                    [minutes] => 30
                    [seconds] => 00
                    [mon] => 08
                    [mday] => 11
                    [year] => 2019
                    [wday] => 0
                )

            [timezone:Date:private] => America/New_York
            [timestring:Date:private] => 2019-08-11 08:30:00
            [timestamp:Date:private] => 1565526600
        )

    [_displayDate:protected] => Date Object
        (
            [date:Date:private] => DateTime Object
                (
                    [date] => 2019-08-11 00:00:00.000000
                    [timezone_type] => 3
                    [timezone] => America/New_York
                )

            [parts:Date:private] => Array
                (
                    [hours] => 00
                    [minutes] => 00
                    [seconds] => 00
                    [mon] => 08
                    [mday] => 11
                    [year] => 2019
                    [wday] => 0
                )

            [timezone:Date:private] => America/New_York
            [timestring:Date:private] => 2019-08-11 00:00:00
            [timestamp:Date:private] => 1565496000
        )

    [_periodSpan:protected] => 1
    [_reservation:ReservationSlot:private] => ReservationItemView Object
        (
            [ReferenceNumber] => 5d4fddd0c213c992521444
            [StartDate] => Date Object
                (
                    [date:Date:private] => DateTime Object
                        (
                            [date] => 2019-08-11 12:00:00.000000
                            [timezone_type] => 3
                            [timezone] => UTC
                        )

                    [parts:Date:private] => Array
                        (
                            [hours] => 12
                            [minutes] => 00
                            [seconds] => 00
                            [mon] => 08
                            [mday] => 11
                            [year] => 2019
                            [wday] => 0
                        )

                    [timezone:Date:private] => UTC
                    [timestring:Date:private] => 2019-08-11 12:00:00
                    [timestamp:Date:private] => 1565524800
                )

            [EndDate] => Date Object
                (
                    [date:Date:private] => DateTime Object
                        (
                            [date] => 2019-08-11 12:30:00.000000
                            [timezone_type] => 3
                            [timezone] => UTC
                        )

                    [parts:Date:private] => Array
                        (
                            [hours] => 12
                            [minutes] => 30
                            [seconds] => 00
                            [mon] => 08
                            [mday] => 11
                            [year] => 2019
                            [wday] => 0
                        )

                    [timezone:Date:private] => UTC
                    [timestring:Date:private] => 2019-08-11 12:30:00
                    [timestamp:Date:private] => 1565526600
                )

            [Date] => DateRange Object
                (
                    [_begin:DateRange:private] => Date Object
                        (
                            [date:Date:private] => DateTime Object
                                (
                                    [date] => 2019-08-11 12:00:00.000000
                                    [timezone_type] => 3
                                    [timezone] => UTC
                                )

                            [parts:Date:private] => Array
                                (
                                    [hours] => 12
                                    [minutes] => 00
                                    [seconds] => 00
                                    [mon] => 08
                                    [mday] => 11
                                    [year] => 2019
                                    [wday] => 0
                                )

                            [timezone:Date:private] => UTC
                            [timestring:Date:private] => 2019-08-11 12:00:00
                            [timestamp:Date:private] => 1565524800
                        )

                    [_end:DateRange:private] => Date Object
                        (
                            [date:Date:private] => DateTime Object
                                (
                                    [date] => 2019-08-11 12:30:00.000000
                                    [timezone_type] => 3
                                    [timezone] => UTC
                                )

                            [parts:Date:private] => Array
                                (
                                    [hours] => 12
                                    [minutes] => 30
                                    [seconds] => 00
                                    [mon] => 08
                                    [mday] => 11
                                    [year] => 2019
                                    [wday] => 0
                                )

                            [timezone:Date:private] => UTC
                            [timestring:Date:private] => 2019-08-11 12:30:00
                            [timestamp:Date:private] => 1565526600
                        )

                    [_timezone:DateRange:private] => UTC
                    [weekdays:DateRange:private] => 0
                    [weekends:DateRange:private] => 0
                )

            [ResourceName] => Conference Room 1
            [ReservationId] => 3
            [UserLevelId] => 1
            [Title] => Dev test
            [Description] => Dev test
            [ScheduleId] => 1
            [FirstName] => Vincent
            [LastName] => Armedilla
            [UserId] => 7
            [CreatedDate] => Date Object
                (
                    [date:Date:private] => DateTime Object
                        (
                            [date] => 2019-08-11 09:20:16.000000
                            [timezone_type] => 3
                            [timezone] => UTC
                        )

                    [parts:Date:private] => Array
                        (
                            [hours] => 09
                            [minutes] => 20
                            [seconds] => 16
                            [mon] => 08
                            [mday] => 11
                            [year] => 2019
                            [wday] => 0
                        )

                    [timezone:Date:private] => UTC
                    [timestring:Date:private] => 2019-08-11 09:20:16
                    [timestamp:Date:private] => 1565515216
                )

            [DateCreated] => Date Object
                (
                    [date:Date:private] => DateTime Object
                        (
                            [date] => 2019-08-11 09:20:16.000000
                            [timezone_type] => 3
                            [timezone] => UTC
                        )

                    [parts:Date:private] => Array
                        (
                            [hours] => 09
                            [minutes] => 20
                            [seconds] => 16
                            [mon] => 08
                            [mday] => 11
                            [year] => 2019
                            [wday] => 0
                        )

                    [timezone:Date:private] => UTC
                    [timestring:Date:private] => 2019-08-11 09:20:16
                    [timestamp:Date:private] => 1565515216
                )

            [ModifiedDate] =>
            [IsRecurring] =>
            [RequiresApproval] =>
            [RepeatType] => none
            [RepeatInterval] =>
            [RepeatWeekdays] =>
            [RepeatMonthlyType] =>
            [RepeatTerminationDate] =>
            [OwnerId] => 7
            [OwnerEmailAddress] => vmbarmedilla@gmail.com
            [OwnerPhone] =>
            [OwnerOrganization] =>
            [OwnerPosition] =>
            [OwnerLanguage] => en_us
            [OwnerTimezone] => America/New_York
            [SeriesId] => 3
            [ParticipantIds] => Array
                (
                    [0] => 11
                )

            [ParticipantNames] => Array
                (
                    [11] => jresource jresource
                )

            [InviteeIds] => Array
                (
                )

            [InviteeNames] => Array
                (
                )

            [Attributes] => CustomAttributes Object
                (
                    [attributes:CustomAttributes:private] => Array
                        (
                            [1] => 34567
                            [2] => 12345
                        )

                )

            [UserPreferences] => UserPreferences Object
                (
                    [preferences:UserPreferences:private] => Array
                        (
                            [CalendarFilter] => ||
                        )

                    [changed:UserPreferences:private] => Array
                        (
                        )

                    [added:UserPreferences:private] => Array
                        (
                        )

                )

            [ResourceStatusId] => 1
            [ResourceStatusReasonId] =>
            [StartReminder] =>
            [EndReminder] =>
            [ResourceColor] =>
            [ResourceId] => 1
            [OwnerFirstName] => Vincent
            [OwnerLastName] => Armedilla
            [CheckinDate] => NullDate Object
                (
                    [date:Date:private] =>
                    [parts:Date:private] =>
                    [timezone:Date:private] =>
                    [timestring:Date:private] =>
                    [timestamp:Date:private] =>
                )

            [CheckoutDate] => NullDate Object
                (
                    [date:Date:private] =>
                    [parts:Date:private] =>
                    [timezone:Date:private] =>
                    [timestring:Date:private] =>
                    [timestamp:Date:private] =>
                )

            [IsCheckInEnabled] =>
            [AutoReleaseMinutes] =>
            [OriginalEndDate] => NullDate Object
                (
                    [date:Date:private] =>
                    [parts:Date:private] =>
                    [timezone:Date:private] =>
                    [timestring:Date:private] =>
                    [timestamp:Date:private] =>
                )

            [CreditsConsumed] =>
            [ParticipatingGuests] => Array
                (
                )

            [InvitedGuests] => Array
                (
                )

            [ResourceNames] => Array
                (
                    [0] => Conference Room 1
                )

            [ResourceAdminGroupId] => 10
            [ScheduleAdminGroupId] =>
            [bufferSeconds:ReservationItemView:private] => 0
            [ownerGroupIds:ReservationItemView:private] => Array
                (
                    [0] => 9
                )

            [_color:ReservationItemView:private] =>
            [_colorRules:ReservationItemView:private] => Array
                (
                )

        )

    [_beginSlotId:protected] => 15655248005d503aa7b84f9
    [_endSlotId:protected] => 15655248005d503aa7b84f9
    [_beginPeriod:protected] => SchedulePeriod Object
        (
            [_begin:protected] => Date Object
                (
                    [date:Date:private] => DateTime Object
                        (
                            [date] => 2019-08-11 08:00:00.000000
                            [timezone_type] => 3
                            [timezone] => America/New_York
                        )

                    [parts:Date:private] => Array
                        (
                            [hours] => 08
                            [minutes] => 00
                            [seconds] => 00
                            [mon] => 08
                            [mday] => 11
                            [year] => 2019
                            [wday] => 0
                        )

                    [timezone:Date:private] => America/New_York
                    [timestring:Date:private] => 2019-08-11 08:00:00
                    [timestamp:Date:private] => 1565524800
                )

            [_end:protected] => Date Object
                (
                    [date:Date:private] => DateTime Object
                        (
                            [date] => 2019-08-11 08:30:00.000000
                            [timezone_type] => 3
                            [timezone] => America/New_York
                        )

                    [parts:Date:private] => Array
                        (
                            [hours] => 08
                            [minutes] => 30
                            [seconds] => 00
                            [mon] => 08
                            [mday] => 11
                            [year] => 2019
                            [wday] => 0
                        )

                    [timezone:Date:private] => America/New_York
                    [timestring:Date:private] => 2019-08-11 08:30:00
                    [timestamp:Date:private] => 1565526600
                )

            [_label:protected] =>
            [_id:protected] => 15655248005d503aa7b84f9
        )

    [_endPeriod:protected] => SchedulePeriod Object
        (
            [_begin:protected] => Date Object
                (
                    [date:Date:private] => DateTime Object
                        (
                            [date] => 2019-08-11 08:00:00.000000
                            [timezone_type] => 3
                            [timezone] => America/New_York
                        )

                    [parts:Date:private] => Array
                        (
                            [hours] => 08
                            [minutes] => 00
                            [seconds] => 00
                            [mon] => 08
                            [mday] => 11
                            [year] => 2019
                            [wday] => 0
                        )

                    [timezone:Date:private] => America/New_York
                    [timestring:Date:private] => 2019-08-11 08:00:00
                    [timestamp:Date:private] => 1565524800
                )

            [_end:protected] => Date Object
                (
                    [date:Date:private] => DateTime Object
                        (
                            [date] => 2019-08-11 08:30:00.000000
                            [timezone_type] => 3
                            [timezone] => America/New_York
                        )

                    [parts:Date:private] => Array
                        (
                            [hours] => 08
                            [minutes] => 30
                            [seconds] => 00
                            [mon] => 08
                            [mday] => 11
                            [year] => 2019
                            [wday] => 0
                        )

                    [timezone:Date:private] => America/New_York
                    [timestring:Date:private] => 2019-08-11 08:30:00
                    [timestamp:Date:private] => 1565526600
                )

            [_label:protected] =>
            [_id:protected] => 15655248005d503aa7b84f9
        )

)
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sun Aug 11, 2019 6:03 pm    Post subject: Reply with quote

You can't access it directly, as it's in a private property.
Back to top
View user's profile Send private message
vmbarmedilla
Smarty n00b


Joined: 11 Aug 2019
Posts: 2

PostPosted: Sun Aug 11, 2019 11:30 pm    Post subject: Reply with quote

AnrDaemon wrote:
You can't access it directly, as it's in a private property.


hello AnrDaemon, thank you for you quick response. But when i print this i can access it {$Slot->Label()}. How can i access the value directly? Thank you
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Wed Aug 21, 2019 8:17 am    Post subject: Reply with quote

Read my previous answer.
If you can access it via getter, use getter.
Back to top
View user's profile Send private message
bsmither
Smarty Elite


Joined: 20 Dec 2011
Posts: 322
Location: West Coast

PostPosted: Thu Aug 22, 2019 1:40 am    Post subject: Reply with quote

If {$slot->label()} gives you the posted array, then try assigning that result to a render-time variable:
Code:
{assign var="arrSlot" value=$slot->label()}

Then, dig down to the array you want:
Code:
{$arrSlot._reservation.Attributes.attributes[1]}
{$arrSlot._reservation.Attributes.attributes[2]}
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP