DominicKleinDominicKlein MitarbeiterKommentare: 0 Danke erhalten: 0 Mitglied seit: Juli 2017 bearbeitet 30. Januar

Shopware Developer Training Basic

1 - Controllerrouten und Authentifizierung / Controller routes & authentication

<?php

class Shopware_Controllers_Frontend_SessionInfo extends Enlight_Controller_Action
{
    public function userAction() {
        $this->view->userId = $this->get('session')->get('sUserId');
    }
}

2 - Subscriber-Methode und Registrierung eines Template-Ordners / Subscriber method and registering a template directory

<?php

namespace EventPlugin;

use Shopware\Components\Plugin;
use \Enlight_Controller_ActionEventArgs as ActionEventArgs;

class EventPlugin extends Plugin
{
    public static function getSubscribedEvents()
    {
        return [
            'Enlight_Controller_Action_PostDispatch_Frontend' => 'mySubscriber'
        ];
    }

    public function mySubscriber(ActionEventArgs $args) {
        $args->getSubject()->View()->addTemplateDir(__DIR__ . '/Resources/views/');
    }
}
Anmelden oder Registrieren, um zu kommentieren.