Coder Social home page Coder Social logo

Comments (5)

cwittstock avatar cwittstock commented on April 28, 2024

You have to insert the setContainer-Call in the Resources/config/services/controllers.xml like this:

<service id="Adyen\Shopware\Storefront\Controller\NotificationReceiverController">  
	<argument type="service" id="Adyen\Shopware\Service\NotificationReceiverService"/>  
	<call method="setContainer">  
		<argument type="service" id="service_container"/>  
	</call>  
	<tag name="controller.service_arguments"/>  
</service>

from adyen-shopware6.

andydandy80 avatar andydandy80 commented on April 28, 2024

me or the plugin? :-)

from adyen-shopware6.

cwittstock avatar cwittstock commented on April 28, 2024

adyen of course, but now you have a workaround. ;-)

from adyen-shopware6.

andydandy80 avatar andydandy80 commented on April 28, 2024

Thanks a lot. Workaround is working, a new plugin release would be nice.

from adyen-shopware6.

ntzrbtr avatar ntzrbtr commented on April 28, 2024

If you don't want to touch the plugin, you can also fix this in your own plugin (e.g. theme) via a compiler pass:

<?php

declare(strict_types=1);

namespace MyPlugin\DependencyInjection;

/**
 * Add potentially missing method call to set the container for a controller
 */
class AdyenCompilerPass implements \Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface
{

    /**
     * @inheritDoc
     */
    public function process(\Symfony\Component\DependencyInjection\ContainerBuilder $container)
    {
        $class = 'Adyen\\Shopware\\Storefront\\Controller\\NotificationReceiverController';

        if (!$container->has($class)) {
            return;
        }

        $definition = $container->getDefinition($class);
        if (!$definition->hasMethodCall('setContainer')) {
            $definition->addMethodCall(
                'setContainer',
                [new \Symfony\Component\DependencyInjection\Reference('service_container')]
            );
        }
    }
}

The compiler pass must then be registered in your plugin class:

<?php

declare(strict_types=1);

namespace MyPlugin;

use Shopware\Core\Framework\Plugin;
use Shopware\Storefront\Framework\ThemeInterface;
use Shopware\Core\Framework\Plugin\Context\UpdateContext;
use Shopware\Core\System\CustomField\CustomFieldTypes;

/**
 * Plugin class
 */
class MyPlugin extends Plugin
{
    /**
     * @inheritDoc
     */
    public function build(\Symfony\Component\DependencyInjection\ContainerBuilder $container): void
    {
        // Call parent method first.
        parent::build($container);

        // Add compiler pass to fix controller in the Adyen plugin.
        $container->addCompilerPass(new \MyPlugin\DependencyInjection\AdyenCompilerPass());
    }
}

from adyen-shopware6.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.