odata-client-php icon indicating copy to clipboard operation
odata-client-php copied to clipboard

How to access nested Properties?

Open nafwa03 opened this issue 5 years ago • 1 comments
trafficstars

I can get to the entities no problem but what I am unable to figure out is to access properties from a created entity set. The Odata provider is sharefile. For example, my selects for this are not working:

$yada->select('Id,Name,CreatorNameShort,Info,Info/IsAHomeFolder,Children/Id,Children/Name,Children/CreationDate,Children/FileSizeBytes,Children/CreatorNameShort,Children/FileCount');

This has a root folder structure followed by the child folders. This would be root where users see folders, etc..

Access to a folder directly is same minus a has specified for the specific item.

What I am trying to achieve, if it is possible with this, is to create an entity collection like..

$my_collection I create. then $my_collection2->from($my_collection) etc

I am unable to retrieve the properties as if I was using direct php property_exists...

Is this supported?

nafwa03 avatar Jul 26 '20 17:07 nafwa03

I was able to solve it partly by removing the 'Items' from the baseurl. Great documentation ;(. Now it is working correctly if I use it in the from as $my_entity->from('Items')->expand('Children)'

I am still trying to figure out how to access the properties to do my own parsing. From what I have do I need to create a new STDClass for each entity and then access them that way or how can I get access if its even possible at current code state?

object(SaintSystems\OData\Entity)#374 (16) { ["primaryKey":protected]=> string(2) "id" ["perPage":protected]=> int(25) ["properties":protected]=> array(2) { ["Children"]=> array(2) { [0]=> array(6) { ["FileCount"]=> int(0) ["CreationDate"]=> string(23) "2020-01-29T15:53:57.14Z" ["FileSizeBytes"]=> int(0) ["CreatorNameShort"]=> string(11) "ME" ["odata.metadata"]=> string(88) "https://domain.sf-api.com/sf/v3/$metadata#Items/ShareFile.Api.Models.Folder@Element" ["Id"]=> string(36) "fbf80yuyuyd8" } [1]=> array(6) { ["FileCount"]=> int(0) ["CreationDate"]=> string(24) "2020-01-28T18:55:02.787Z" ["FileSizeBytes"]=> int(0) ["CreatorNameShort"]=> string(11) "YOU" ["odata.metadata"]=> string(88) "https://domain.sf-api.com/sf/v3/$metadata#Items/ShareFile.Api.Models.Folder@Element" ["Id"]=> string(36) "fbwewef80yuyuyd8" }``

nafwa03 avatar Jul 26 '20 19:07 nafwa03