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

Support interface/superclass based mapping in SchemaContainer #254

Open
samizdam opened this issue May 13, 2021 · 1 comment
Open

Support interface/superclass based mapping in SchemaContainer #254

samizdam opened this issue May 13, 2021 · 1 comment

Comments

@samizdam
Copy link

Case: I have multiple implementation for my entity interface and one schema for all it.

Now SchemaContainer

  • use class_exists(), but not interface_exists()
  • use get_classs() for check instance type - and known only about last class from object class parents

New logic for support interface/superclass in map for encoder should check class hierarchy in entries.

Now I need create proxy for all resource and wrap all data entries in my request handler.
Another possible ugly way - write every final implementation to encoder map with dublicated schema. Manual to config file, or generate by some rules (scan sources, annotations, etc). 20-50 entries in my case.

@issa
Copy link

issa commented May 21, 2021

I had to create a subclass of SchemaContainer containing this:

    public function register(string $type, $schema): void
    {
        if (true === empty($type) || (false === \class_exists($type) && false === \interface_exists($type))) {
            throw new InvalidArgumentException(_(static::MSG_INVALID_MODEL_TYPE));
        }
    // …

But I would prefer to not have to do this as well.

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