Issue
so my variable contains an array of objects. each object is like this
Array
(
[0] => CustomAudienceBean Object
(
[limit:protected] =>
[account_id:protected] => 2342354235235
[approximate_account:protected] =>
[data_source:protected] => stdClass Object
(
[type] => SEED_BASED
[sub_type] => ENGAGEMENT_EVENT_USERS
[creation_params] => []
)
[type:protected] =>
[sub_type:protected] =>
[creation_params:protected] => Array
(
)
[delivery_status:protected] => stdClass Object
(
[code] => 300
[description] => Audiences must include at least 20 people to be used for ads.
)
[code:protected] =>
[description:protected] =>
[external_event_source:protected] =>
[id:protected] => 23423asdf23423tadf23
[is_value_based:protected] =>
[lookalike_audience_ids:protected] =>
[lookalike_spec:protected] => stdClass Object
It's quite deep.. how to convert the array into a ArrayDataProvider in yii
Solution
I think there's no out of the box way. Your CustomAudienceBean
object's properties are protected, so you can't access them directly. You have to extend the class if there are no public methods.
You have 2 options,
Extend
CustomAudienceBean
class and define a method to return all the properties you need. Then iterate your dataset and build the array forCArrayDataProvider
Extend the
CArrayDataProvider
and feed your array of objects. Then inside your customArrayDataProvider
you can extract the properties fromCustomAudienceBean
object
Answered By - Gihan
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.