Backend example


    private $export;

    /** * Init controller method * * Disables the authorization-checking and template renderer. */
    public function init()
    {
        Shopware()->Plugins()->Backend()->Auth()->setNoAuth();
        Shopware()->Front()->Plugins()->ViewRenderer()->setNoRender();
        $this->Front()->setParam('disableOutputBuffering', true);
        $this->export = Shopware()->Modules()->Export();
    }

    /** * Index action method * * Creates the export product. */
    public function indexAction()
    {
/** * Helper method to do particular in code acl checks * * @param string|null $privilege Name of privilege * @param string|Zend_Acl_Role_Interface|null $resource * @param string|Zend_Acl_Resource_Interface|null $role * * @return bool */
    protected function _isAllowed($privilege$resource = null, $role = null)
    {
        return Shopware()->Plugins()->Backend()->Auth()->isAllowed([
            'privilege' => $privilege,
            'resource' => $resource,
            'role' => $role,
        ]);
    }

    /** * @param mixed|null $identity * * @return string */
    

    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');
        }
    }

    /** * Displays a JSON string indicating failure for password confirmation */
    public function passwordConfirmationRequiredAction()
    {

    protected $auth;

    /** * Loads auth and script renderer resource * * @return void */
    public function init()
    {
        $this->auth = Shopware()->Plugins()->Backend()->Auth();
        $this->auth->setNoAuth();
        $this->Front()->Plugins()->ScriptRenderer()->setRender();
    }

    /** * {@inheritdoc} */
    public function getWhitelistedCSRFActions()
    {
        return [
            'index',
            


use Shopware\Components\CSRFWhitelistAware;
use Symfony\Component\HttpFoundation\Response;

class Shopware_Controllers_Backend_Cron extends Enlight_Controller_Action implements CSRFWhitelistAware
{
    public function init()
    {
        Shopware()->Plugins()->Backend()->Auth()->setNoAuth();
        Shopware()->Front()->Plugins()->ViewRenderer()->setNoRender();
    }

    public function indexAction()
    {
        if (!Shopware()->Plugins()->Core()->Cron()->authorizeCronAction($this->Request())) {
            $this->Response()
                ->clearHeaders()
                ->setStatusCode(Response::HTTP_FORBIDDEN)
                ->appendBody('Forbidden');

            

    public function init()
    {
        if (!$this->Request()->getActionName()
            || \in_array($this->Request()->getActionName()['index', 'load'])
        ) {
            $this->View()->addTemplateDir('.');
            $this->Front()->Plugins()->ScriptRenderer()->setRender();
            Shopware()->Plugins()->Backend()->Auth()->setNoAuth();
        } else {
            parent::init();
        }
    }

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

    protected $countryRepository;

    /** * Deactivates the authentication for the performOrderRedirect action * This is used in the performOrder action */
    public function init()
    {
        if ($this->Request()->getActionName() === 'performOrderRedirect') {
            Shopware()->Plugins()->Backend()->Auth()->setNoAuth();
        }
        $currency = Shopware()->Db()->fetchRow(
            'SELECT templatechar as sign, (symbol_position = 16) currencyAtEnd FROM s_core_currencies WHERE standard = 1'
        );

        $this->View()->assign('currency', $currency);

        parent::init();
    }

    
use Shopware\Components\CSRFWhitelistAware;
use Shopware\Models\Shop\Locale;
use Shopware\Models\User\Role;

class Shopware_Controllers_Backend_Login extends Shopware_Controllers_Backend_ExtJs implements CSRFWhitelistAware
{
    /** * Loads auth and script renderer resource */
    public function init()
    {
        Shopware()->Plugins()->Backend()->Auth()->setNoAuth();
        parent::init();
    }

    /** * {@inheritdoc} */
    public function getWhitelistedCSRFActions()
    {
        return [
            'login',
            'logout',
            
use Symfony\Component\HttpFoundation\Response;

class Shopware_Controllers_Backend_Newsletter extends Enlight_Controller_Action implements CSRFWhitelistAware
{
    /** * Init controller method * * Disables the authorization-checking and template renderer. */
    public function init()
    {
        Shopware()->Plugins()->Backend()->Auth()->setNoAuth();
        Shopware()->Front()->Plugins()->ViewRenderer()->setNoRender();
    }

    /** * {@inheritdoc} */
    public function getWhitelistedCSRFActions()
    {
        return [
            'view',
            'index',
            
$this->connection = $connection;
        $this->pluginExtractor = $pluginExtractor;
        $this->httpClient = $httpClient;
    }

    /** * @return FinishResult|ValidResult */
    public function downloadRange(RangeDownloadRequest $request)
    {
        // Load SwagUpdate so the DownloadStep can be auto-loaded         Shopware()->Plugins()->Backend()->SwagUpdate();

        $version = new Version([
            'uri' => $request->getUri(),
            'size' => $request->getSize(),
            'sha1' => $request->getSha1(),
        ]);

        return (new DownloadStep($version$request->getDestination()))->run($request->getOffset());
    }

    /** * @param string $file * @param string $pluginName * * @throws Exception */


    /** * Gets the available backend locales excluding the current one * * @return void */
    public function getAlternativeLocalesAction()
    {
        $targetLocale = Shopware()->Container()->get('auth')->getIdentity()->locale;

        $locales = Shopware()->Plugins()->Backend()->Auth()->getLocales();

        if (($key = array_search($targetLocale->getId()$locales)) !== false) {
            unset($locales[$key]);
        }

        $locales = Shopware()->Db()->quote($locales);
        $sql = 'SELECT id, locale FROM s_core_locales WHERE id IN (' . $locales . ')';
        $locales = Shopware()->Db()->fetchPairs($sql);

        $data = [];
        foreach ($locales as $id => $locale) {
            
use Shopware\Components\CSRFTokenValidator;
use Shopware\Components\CSRFWhitelistAware;
use Shopware\Components\Random;

class Shopware_Controllers_Backend_CSRFToken extends Shopware_Controllers_Backend_ExtJs implements CSRFWhitelistAware
{
    /** * Loads auth and script renderer resource */
    public function init()
    {
        Shopware()->Plugins()->Backend()->Auth()->setNoAuth();
        $this->Front()->Plugins()->ViewRenderer()->setNoRender();
        parent::init();
    }

    /** * {@inheritdoc} */
    public function getWhitelistedCSRFActions()
    {
        return [
            'generate',
        ];
Home | Imprint | This part of the site doesn't use cookies.