Skip to content

[5.x] Add support for public properties to PathDataManager #11697

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: 5.x
Choose a base branch
from

Conversation

marcorieser
Copy link
Contributor

@marcorieser marcorieser commented Apr 14, 2025

This PR adds support for accessing public properties on plain objects (non-augmentable / non-arrayaccess).

Backstory:
In the Statamic Livewire addon, I've added support for computed properties. Objects returned from there are not always augmentable objects. So I thought it would be nice to be able to process those objects in Antlers, too, meaning calling public methods and accessing public properties (on non-augmentable / non-arrayaccess objects).

{{ livewire:computed:property:nested_path:plain_object:public_method }}
{{ livewire:computed:property:nested_path:plain_object:public_property }}
class Dummy
{
    public string $public_property = 'Public Property';

    public function publicMethod()
    {
        return 'Public Method';
    }
}

I started iterating the path segments and handling all the different types of values/objects myself, but then realized Statamic already can do that (but didn't find the correct place where this is handled in the runtime parser). I had a quick talk with Duncan and John Koster on how to handle that. We (basically John 😅) figured out, it's the PathDataManager. This works perfectly, but it currently doesn't check for public properties on objects.

https://discord.com/channels/489818810157891584/1360647492701519963

@marcorieser marcorieser changed the title Add support for public properties to PathDataManager [5.x] Add support for public properties to PathDataManager Apr 14, 2025
@jasonvarga
Copy link
Member

Please edit the description to explain the PR.

@marcorieser
Copy link
Contributor Author

Sure, will do. It's currently just a draft.

@marcorieser

This comment was marked as outdated.

@marcorieser marcorieser marked this pull request as ready for review April 16, 2025 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants