You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add nested property access support for OData entities (#187)
* Initial plan
* Implement nested property access for OData entities
- Add support for object-style nested property access (entity->Info->IsAHomeFolder)
- Add dot notation property access via getProperty('Info.IsAHomeFolder')
- Convert nested associative arrays to Entity objects automatically
- Add hasProperty() method for checking property existence with dot notation
- Maintain full backward compatibility with existing flat property access
- Preserve array access functionality for both nested and flat properties
- Support deep nesting (unlimited levels)
- Handle both complex objects and arrays appropriately
Addresses the ShareFile OData scenario where users need to access nested
properties like Info/IsAHomeFolder and work with collection filtering.
Co-authored-by: anderly <[email protected]>
* Add comprehensive integration tests for nested properties with TripPinService People endpoint
Co-authored-by: anderly <[email protected]>
* Fix static property typo and method name conflict in Entity class
- Fix typo: $snakePropreties -> $snakeProperties
- Add missing static property declaration for $snakeProperties with default value false
- Rename getNestedProperty() to getNestedPropertyByPath() to avoid conflict with automatic mutator detection for 'nested' property
- Resolves 18 test failures caused by undeclared static property error
Co-authored-by: anderly <[email protected]>
* Add comprehensive nested property access documentation and examples
Co-authored-by: anderly <[email protected]>
* Move Guzzle back to require-dev dependencies
Co-authored-by: anderly <[email protected]>
* Restore PHPUnit version specification to ^9.5 || ^10.0 || ^11.0 || ^12.0
Co-authored-by: anderly <[email protected]>
---------
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: anderly <[email protected]>
Copy file name to clipboardExpand all lines: README.md
+177Lines changed: 177 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -231,6 +231,183 @@ This approach allows you to customize request creation without having to overrid
231
231
232
232
For a complete working example, see [`examples/custom_headers_example.php`](examples/custom_headers_example.php).
233
233
234
+
### Nested Property Access
235
+
236
+
The OData Client provides powerful support for accessing nested properties in OData entities, making it easy to work with complex data structures returned by modern OData services.
237
+
238
+
#### Object-Style Access
239
+
240
+
Access nested properties naturally using object notation:
241
+
242
+
```php
243
+
<?php
244
+
245
+
use SaintSystems\OData\ODataClient;
246
+
use SaintSystems\OData\GuzzleHttpProvider;
247
+
248
+
$httpProvider = new GuzzleHttpProvider();
249
+
$client = new ODataClient('https://services.odata.org/V4/TripPinService', null, $httpProvider);
-**Multiple Access Patterns**: Object notation, dot notation, and array access all supported
403
+
-**Automatic Type Conversion**: Nested associative arrays become Entity objects for object-style access
404
+
-**Safe Navigation**: Non-existent properties return `null` instead of throwing errors
405
+
-**Performance Optimized**: Entity objects created lazily only when accessed
406
+
-**Backward Compatible**: All existing code continues to work unchanged
407
+
-**Collection Friendly**: Arrays remain as arrays for easy filtering and manipulation
408
+
409
+
For comprehensive examples and advanced usage patterns, see [`examples/nested_properties_example.php`](examples/nested_properties_example.php).
410
+
234
411
### Lambda Operators (any/all)
235
412
236
413
The OData Client supports lambda operators `any` and `all` for filtering collections within entities. These operators allow you to filter based on conditions within related navigation properties.
0 commit comments