Wie kann ich Shopware Evnet-Subscriber richtig benutzen

Hi, I’ve created a custom plugin SwagStartup in Shopware, and it works by calling an url like “shopware.project/myDemo”.

Then I tried to define/use event subscriber in this plugin, following is the code:

 

namespace SwagStartup\Subscriber;
use Enlight\Event\SubscriberInterface;

class RoutingSubscriber implements SubscriberInterface
{
    public static function getSubscribedEvents(){
        return ['Enlight_Controller_Action_PreDispatch' => 'onPreDispatch'];
    }
    public function onPreDispatch(Enlight_Event_EventArgs $args){
        die('here!');
    }
}

And the XML file: Resources/services.xml:

When I called the url like before, I expected to see the output from the die() function, cause I thought the event Enlight_Controller_Action_PreDispatch should have been caught by the subscriber and the funciton onPreDispatch() should have been called - but it was not the case.

What’s wrong? Can someone tell me?

Problem bereits geloest!

Und wie sieht die Lösung aus oder war es heilen durch Hand auflegen? :slight_smile: