dediagency / sylius-seo-plugin

Sylius SEO Plugin by Dedi.
26 stars 24 forks source link

Impossible to decorate ProductUrlGenerator #28

Closed Roshyo closed 1 year ago

Roshyo commented 2 years ago

Problem: When one decorates Dedi\SyliusSEOPlugin\Factory\SubjectUrl\ProductUrlGenerator with its custom implementation, the product show page breaks with the following error:

Dedi\SyliusSEOPlugin\Factory\ProductRichSnippetFactory::__construct(): Argument #6 ($productUrlGenerator) must be of type Dedi\SyliusSEOPlugin\Factory\SubjectUrl\ProductUrlGenerator, App\Factory\SubjectUrl\ProductUrlGenerator given

This is due to Dedi\SyliusSEOPlugin\Factory\ProductRichSnippetFactory typing its argument to Dedi\SyliusSEOPlugin\Factory\SubjectUrl\ProductUrlGenerator instead of Dedi\SyliusSEOPlugin\Domain\SEO\Factory\SubjectUrl\SubjectUrlGeneratorInterface

Proposed solution: Type the argument to the interface instead of the class

Other solution: An other workaround would be to not decorate, but extend the original service instead. But IMO the decoration should work properyl.

JulienLoison commented 1 year ago

This was merged and fixed. I had to reword the commit in order for semantical release to work, losing you as the commit's author, sorry.

Thank you for your contrib @Roshyo