Skip to content
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

Provide example or more documentation for custom dictionary #187

Open
tacman opened this issue Nov 17, 2022 · 0 comments
Open

Provide example or more documentation for custom dictionary #187

tacman opened this issue Nov 17, 2022 · 0 comments
Assignees

Comments

@tacman
Copy link
Contributor

tacman commented Nov 17, 2022

The documentation for defining a custom dictionary is pretty light:

https://github.com/KnpLabs/DictionaryBundle#dictionary

I've created a class that implements Dictionary, and I've set getKeys() and getValues() to return arrays with keys and values, but I'm not sure what I'm supposed to do with offsetGet().

This works, but doesn't feel right:

    public function offsetGet(mixed $offset): mixed
    {
        return array_combine($this->getKeys(), $this->getValues())[$offset];
   }

Is there an example you can point me to? Thx.

@PedroTroller PedroTroller self-assigned this Apr 5, 2023
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

No branches or pull requests

2 participants