adyen-shopware6 icon indicating copy to clipboard operation
adyen-shopware6 copied to clipboard

Various properties in FrontendProxyController do not use the Abstract* version but the constructor does

Open AndreasA opened this issue 2 years ago • 4 comments

Describe the bug

If one e.g. decorates the CartOrderRoute by extending the AbstractCartOrderRoute, it will work for the constructor but fails to be stored in the property as the property typehinting only allows CartOrderRoute directly.

The same is true for various other properties / constructor services.

Versions Shopware version: [e.g. 6.5.4.4] Plugin version: [e.g. 3.12.1]

see e.g. https://github.com/Adyen/adyen-shopware6/blob/3.12.1/src/Storefront/Controller/FrontendProxyController.php#L54 and https://github.com/Adyen/adyen-shopware6/blob/3.12.1/src/Storefront/Controller/FrontendProxyController.php#L63

AndreasA avatar Jul 20 '23 10:07 AndreasA

also: is that controller actually necessary? why not just call the store api directly as I think shopware does also?

AndreasA avatar Jul 20 '23 10:07 AndreasA

@AndreasA this controller was created only to be able to access store-api routes from our frontend components in shopware 6.5 and this is necessary because of this change

peterojo avatar Jul 24 '23 10:07 peterojo

Hi @peterojo

Ok. So did not add another solution regarding proxy routing except to implement a corresponding contorller manually. Weird.

Anyway, my main point was that if I use a service decoration for e.g. Shopware\Core\Checkout\Cart\SalesChannel\CartOrderRoute like:

namespace Foo;

public class DecoratedCartOrderRoute extends AbstractCartOrder {
   ....
}
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance"
    xsd:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd">
    <services>
        <service id="Foo\DecoratedCartOrderRoute "
            decorates="Shopware\Core\Checkout\Cart\SalesChannel\CartOrderRoute"
        />
    </services>
</container>

Routes like /adyen/proxy-switch-context will fail to work as the controller expects the property to be of the type CartOrderRoute not AbstractCartOrderRoute

AndreasA avatar Jul 25 '23 11:07 AndreasA

@peterojo I could create a PR for this, it should be quite straight forward.

AndreasA avatar Jul 27 '23 12:07 AndreasA