dotkernel / api-documentation

Documentation repository for Dotkernel API
MIT License
1 stars 0 forks source link

BookHandler requires $config Property #49

Closed comcduarte closed 3 months ago

comcduarte commented 3 months ago

When running POST to create book, I received an error message

{"error":{"messages":["Undefined property: Api\\Book\\Handler\\BookHandler::$config"]}}

I noticed the the HandlerTrait requires this property, which is present in both the AdminHandler and UserHandler. I added this to the doc and __construct as below and it resolved the issue.

class BookHandler implements RequestHandlerInterface
{
    use HandlerTrait;

    #[Inject(
        HalResponseFactory::class,
        ResourceGenerator::class,
        BookServiceInterface::class,
        "config",
        )]
        public function __construct(
            protected HalResponseFactory $responseFactory,
            protected ResourceGenerator $resourceGenerator,
            protected BookServiceInterface $bookService,
            protected array $config,
            ) {
        }
pinclau commented 3 months ago

Hi @comcduarte , Thank you for notify, indeed that was the problem here. Between the creation of this tutorial and now the Dotkernel api suffered some major changes and somehow this was forgotten. In the latest pull request #51 we updated it to reflect the changes.