chris-at-github
6/24/2015 - 11:25 AM

Hooks und Events

Hooks und Events

<?php

// Klassse::MethodePuplic::before|after|replace

$this->subscribeEvent(
  'sArticles::sGetArticleById::before',
  'onArticleBefore'
);

$this->subscribeEvent(
  'sArticles::sGetArticleById::after',
  'onArticleAfter'
);

$this->subscribeEvent(
  'sArticles::sGetArticleById::replace',
  'onArticleReplace'
);
<?php
//Notify
$this->subscribeEvent(
  'Shopware_Modules_Order_SaveOrder_ProcessDetails',
  'onSaveOrder'
);

//Notify-Until
$this->subscribeEvent(
  'Shopware_Modules_Articles_GetPromotionById_Start',
  'onGetPromotion'
);

//Filter
$this->subscribeEvent(
  'Shopware_Modules_Articles_sGetArticlesByCategory_FilterResult',
  'onGetArticlesByCategory'
);
<?php 

$this->subscribeEvent(
  'Enlight_Controller_Action_PreDispatch',
  'onPreDispatch'
);

$this->subscribeEvent(
  'Enlight_Controller_Action_PostDispatch',
  'onPostDispatch'
);

// Kurzschreibweise
$this->registerController('Frontend', 'ControllerName');

// Secure-Aufruf
$this->subscribeEvent('Enlight_Controller_Action_PostDispatchSecure_Frontend_Detail', 'onSecureDetailPostDispatch');

// -> wird dann nicht mehr benoetigt
if (!$request->isDispatched()
    || $response->isException()
    || $request->getModuleName() != 'frontend'
    || $request->getControllerName() != 'detail') {

    return;
}