preDispatch example

namespace Shopware\Controllers\Backend;

use Shopware\Bundle\StoreFrontBundle\Struct\Search\CustomSorting;
use Shopware\Models\Shop\Shop;
use Shopware_Controllers_Backend_ExtJs;

class ManualSorting extends Shopware_Controllers_Backend_ExtJs
{
    public function preDispatch()
    {
        parent::preDispatch();
        $this->get(\Shopware\Components\ShopRegistrationServiceInterface::class)->registerShop($this->getModelManager()->getRepository(Shop::class)->getActiveDefault());
    }

    public function listAction(int $start = 0, int $limit = 25, int $categoryId = 3, int $sortingId = 1): void
    {
        $sorting = $this->getSorting($categoryId$sortingId);

        $products = $this->get(\Shopware\Components\ManualSorting\ProductLoaderInterface::class)->load($categoryId$start$limit$sorting);

        $this->View()->assign($products);
    }

    

    protected $voucherRepository;

    /** * Disable template engine for all actions * * @codeCoverageIgnore */
    public function preDispatch()
    {
        parent::preDispatch();
        if (\in_array($this->Request()->getActionName()[
            'validateOrderCode', 'validateVoucherCode', 'validateDescription', ])) {
            $this->Front()->Plugins()->Json()->setRenderer(false);
            $this->Front()->Plugins()->ViewRenderer()->setNoRender();
        }
    }

    /** * Deletes a Supplier from the database * * @return void */
/** * @return void */
    public function preDispatch()
    {
        if ($this->Request()->has('format')) {
            $this->format = (string) $this->Request()->getParam('format');

            // Remove limit parameter to export all data.             $this->Request()->setParam('limit', null);
        }
        parent::preDispatch();
    }

    /** * @return void */
    public function init()
    {
        parent::init();
        $currency = Shopware()->Db()->fetchRow(
            'SELECT templatechar as sign, (symbol_position = 16) currencyAtEnd FROM s_core_currencies WHERE standard = 1'
use Symfony\Component\HttpFoundation\FileBag;

class PluginInstaller extends Shopware_Controllers_Backend_ExtJs
{
    /** * @var InstallerService */
    private $pluginManager;

    public function preDispatch()
    {
        parent::preDispatch();

        $this->pluginManager = $this->get(\Shopware\Bundle\PluginInstallerBundle\Service\InstallerService::class);
    }

    public function installPluginAction()
    {
        @set_time_limit(300);

        $plugin = $this->getPluginModel($this->Request()->getParam('technicalName'));

        if (!$plugin instanceof Plugin) {
            
use Shopware\Models\Shop\Shop;

class Shopware_Controllers_Backend_Partner extends Shopware_Controllers_Backend_ExtJs implements CSRFWhitelistAware
{
    /** * Disable template engine for selected actions * * @codeCoverageIgnore */
    public function preDispatch()
    {
        parent::preDispatch();
        if (\in_array($this->Request()->getActionName()['validateTrackingCode', 'mapCustomerAccount'])) {
            $this->Front()->Plugins()->Json()->setRenderer(false);
            $this->Front()->Plugins()->ViewRenderer()->setNoRender();
        }
    }

    /** * {@inheritdoc} */
    public function getWhitelistedCSRFActions()
    {
        


    /** * Some actions from this controller must be password verified before being able to execute them, * this means that the administrator password must be entered again into a dialog box in order to execute * the requested action. * * @see Shopware_Controllers_Backend_Login::validatePasswordAction() */
    public function preDispatch()
    {
        parent::preDispatch();

        $calledAction = $this->Request()->getActionName();

        if (Shopware()->Plugins()->Backend()->Auth()->shouldAuth()
            && $this->isPasswordConfirmProtectedAction($calledAction)
            && !$this->container->get('backendsession')->offsetGet('passwordVerified')
        ) {
            $this->forward('passwordConfirmationRequired');
        }
    }

    
/** * @var AddressServiceInterface */
    private $addressService;

    /** * {@inheritdoc} */
    public function preDispatch()
    {
        parent::preDispatch();
        $this->addressService = $this->get(AddressServiceInterface::class);
    }

    /** * Transfers the address attributes to the according legacy tables. * * Intended to be called from shopware backend via ajax with request parameter `id`. * * @return void */
    public function syncAttributeAction()
    {
Shopware()->Events()->notify(
            __CLASS__ . '_PreDispatch_' . $moduleName,
            $args
        );

        Shopware()->Events()->notify(
            __CLASS__ . '_PreDispatch_' . $this->controller_name,
            $args
        );

        $this->preDispatch();

        if ($this->Request()->isDispatched() && !$this->Response()->isRedirect()) {
            $action_name = $this->Front()->Dispatcher()->getFullActionName($this->Request());

            if (!$event = Shopware()->Events()->notifyUntil(__CLASS__ . '_' . $action_name$args)) {
                $this->$action(...$this->getActionArguments($action));
            }

            $this->postDispatch();
        }

        

    public const FALLBACK_LOCALE = 'en_GB';

    /** * @return void */
    public function preDispatch()
    {
        if (strtolower($this->Request()->getActionName()) === 'index' && $this->checkStoreApi()) {
            $this->getCategoryService()->synchronize();
        }
        parent::preDispatch();
    }

    /** * @return void */
    public function metaDownloadAction()
    {
        try {
            $request = new MetaRequest(
                $this->Request()->getParam('technicalName'),
                $this->getVersion(),
                


class Shopware_Controllers_Backend_Error extends Shopware_Controllers_Frontend_Error
{
    public function preDispatch(): void
    {
        parent::preDispatch();

        $contentType = $this->Request()->getHeader('Content-Type');
        if ($contentType && str_starts_with($contentType, 'application/json')) {
            $this->Front()->Plugins()->Json()->setRenderer();
            $this->View()->assign('success', false);
        }
    }
}
public function setContainer(?Container $loader = null)
    {
        parent::setContainer($loader);

        $this->get('events')->addListener('Enlight_Controller_Plugin_ScriptRenderer_formatControllerName', static function D) {
            return 'ContentType';
        });
    }

    public function preDispatch(): void
    {
        parent::preDispatch();
        $this->View()->Engine()->setCompileId($this->View()->Engine()->getCompileId() . '_' . $this->Request()->getControllerName());
    }

    public function indexAction(): void
    {
        parent::indexAction();
        $this->View()->loadTemplate('backend/content_type/app.js');
    }

    public function postDispatch(): void
    {
        

    /** * @var CacheManager */
    protected $cacheManager;

    /** * {@inheritdoc} */
    public function preDispatch()
    {
        parent::preDispatch();

        $this->cacheManager = $this->get(CacheManager::class);
    }

    /** * Cache info action */
    public function getInfoAction()
    {
        $data = [
            $this->cacheManager->getConfigCacheInfo(),
            

    protected $resource;

    public function __construct(Translation $translation)
    {
        $this->resource = $translation;
        parent::__construct();
    }

    public function preDispatch()
    {
        parent::preDispatch();

        // We still support the old behavior         $request = $this->Request();
        $localeId = $request->getPost('localeId');

        if ($localeId !== null) {
            $request->setPost('shopId', $localeId);
            $request->setPost('localeId', null);
        }
    }

    
Home | Imprint | This part of the site doesn't use cookies.