Let’s say I have a $page object with text and theme fields. I pass that object to a snippet and use the fields like this:
In the template:
snippet('my-snippet', ['page' => $myPage]);
In the snippet:
$page->text()->value();
$page->theme()->value();
My question is - is there a way to overwrite the text or theme values of $myPage before it’s passed to the snippet? I want to do something like this:
I guess I could use $page->clone(). It doesn’t have to be the same object. To quote myself:
My goal is to be able to alter field values in PHP and have the snippet use them as if those were the original values.
If the cloned page object would function the same way as the original one, except with different field values - then I guess $page->clone() would do the job. I’m looking for a solution that wouldn’t lead to unexpected behavior.