Skip to content

Introduce the StructuredFieldAccess interface #11

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

Merged
merged 4 commits into from
Oct 22, 2024

Conversation

nyamsprod
Copy link
Member

The interface allow adding custom structured field. If a class implement the interface it will be able to be added to each DataType with ease.

For instance you will be able to do the following:

$myObject = new class () implements StructuredFieldAccess {
    public function toStructuredField(): StructuredField
    {
        return Item::new(Token::fromString('babayaga'));
    }
};


$instance = InnerList::fromAssociative([$myObject, 'a', true], ['a' => true]);
echo $instance->toHttpValue();
// prints '(babayaga "a" ?1);a' 

On StructuredField creation the toStructuredField method is called and its return value is
used and store in place of the $myObject instance.

@nyamsprod nyamsprod added the enhancement New feature or request label Oct 21, 2024
@nyamsprod nyamsprod self-assigned this Oct 21, 2024
@nyamsprod nyamsprod merged commit 52b2465 into master Oct 22, 2024
14 checks passed
@nyamsprod nyamsprod deleted the feature/improve-extensability branch October 24, 2024 16:01
nyamsprod added a commit that referenced this pull request Oct 26, 2024
Introduces the StructuredFieldProvider interface and adds basic collection methods to ease usage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant