Skip to content

[RFC] Authorize interface as resource #1574

Description

@Nek-

Problem

In my application I use the KnpDictionaryBundle. This bundle provide an interface to implement dictionaries but no resource class (but provide a dictionary registry), which is incompatible with api platform ATM.

I think api platform should authorize interface as a resource because I'm pretty sure it's not the only software to act like this.

Solution

Modify the ExtractorResourceMetadataFactory to support interfaces:

// before
if (!class_exists($resourceClass) || !$resource = $this->extractor->getResources()[$resourceClass] ?? false)

// After
if (!(class_exists($resourceClass) || interface_exists($resourceClass)) || !$resource = $this->extractor->getResources()[$resourceClass] ?? false)

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions