Json example



    /** * @deprecated - Will be private in Shopware 5.8 * * @param array<array<string, string|int|float>> $data * * @return void */
    protected function exportCSV($data)
    {
        $this->Front()->Plugins()->Json()->setRenderer(false);
        $this->Response()->headers->set('content-type', 'text/csv; charset=utf-8');
        $this->Response()->headers->set('content-disposition', 'attachment;filename=' . $this->getCsvFileName());

        echo "\xEF\xBB\xBF";
        $fp = fopen('php://output', 'w');
        if (!\is_resource($fp)) {
            throw new RuntimeException('Could not open stream');
        }

        if (\is_array($data[0])) {
            fputcsv($fparray_keys($data[0]), ';');
        }
/** * 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 */
    public function deleteVoucherAction()
    {
        
/** * Enable json renderer for index / load action * Check acl rules * * @return void */
    public function preDispatch()
    {
        $actions = ['index', 'load', 'skeleton', 'extends', 'mergeDocuments'];
        if (!\in_array($this->Request()->getActionName()$actions)) {
            $this->Front()->Plugins()->Json()->setRenderer();
        }
    }

    /** * {@inheritdoc} */
    public function getWhitelistedCSRFActions()
    {
        return [
            'openPdf',
            'createDocument',
            
public function authAction()
    {
    }

    /** * Allows changing the locale by sending a Shopware localeId or an ISO-3166 locale (e.g. de_DE) * * @return void */
    public function changeLocaleAction()
    {
        $this->Front()->Plugins()->Json()->setRenderer();

        $localeId = $this->Request()->getParam('localeId');
        if (!$localeId) {
            $this->View()->assign([
                'success' => false,
                'message' => false,
            ]);

            return;
        }

        
&& !$this->container->get('backendsession')->offsetGet('passwordVerified')
        ) {
            $this->forward('passwordConfirmationRequired');
        }
    }

    /** * Displays a JSON string indicating failure for password confirmation */
    public function passwordConfirmationRequiredAction()
    {
        $this->Front()->Plugins()->Json()->setRenderer();

        $this->View()->assign([
            'success' => false,
            'data' => [],
        ]);
    }

    /** * If the requested action is meant to be password verified, unset the session flag in order * for it not to persist in other requests. In this way, the password verification process will be triggered * again. * * @see Shopware_Controllers_Backend_Login::validatePasswordAction() */


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);
        }
    }
}
$this->addAclPermission('duplicateArticle', 'save', 'Insufficient Permissions');
        $this->addAclPermission('save', 'save', 'Insufficient Permissions');
        $this->addAclPermission('delete', 'delete', 'Insufficient Permissions');
    }

    /** * Disable template engine for all actions */
    public function preDispatch()
    {
        if (!\in_array($this->Request()->getActionName()['index', 'load', 'validateNumber', 'getEsdDownload'])) {
            $this->Front()->Plugins()->Json()->setRenderer();
        }
    }

    /** * {@inheritdoc} */
    public function getWhitelistedCSRFActions()
    {
        return [
            'previewDetail',
            'getEsdDownload',
        ];
$this->addAclPermission('createPremiumArticle', 'create', "You're not allowed to create an article.");
        $this->addAclPermission('editPremiumArticle', 'update', "You're not allowed to update the article.");
        $this->addAclPermission('deletePremiumArticle', 'delete', "You're not allowed to delete the article.");
    }

    /** * Disable template engine for all actions */
    public function preDispatch()
    {
        if (!\in_array($this->Request()->getActionName()['index', 'load', 'validateArticle'])) {
            $this->Front()->Plugins()->Json()->setRenderer(true);
        }
    }

    public function getSubShopsAction()
    {
        // load shop repository         $repository = $this->get('models')->getRepository(Shop::class);

        $builder = $repository->createQueryBuilder('shops');
        $builder->select([
            'shops.id as id',
            

        $this->renderPayPalView('start');
    }

    /** * renderPayPalView is a helper-method to render templates for the PayPal integration in * the First-Run-Wizard. */
    private function renderPayPalView(string $view): void
    {
        $this->get('plugins')->Controller()->ViewRenderer()->setNoRender(false);
        $this->Front()->Plugins()->Json()->setRenderer(false);

        $this->View()->loadTemplate(sprintf('backend/first_run_wizard/template/%s.tpl', $view));
    }

    private function getVersion(): string
    {
        $version = $this->container->getParameter('shopware.release.version');

        if (!\is_string($version)) {
            throw new RuntimeException('Parameter shopware.release.version has to be an string');
        }

        

        $this->em = $em;
        $this->ipAnonymizer = $ipAnonymizer;
    }

    /** * This method is called when a new log is made automatically. * It sets the different values and saves the log into `s_core_log` */
    public function createLogAction(Request $request)
    {
        $this->front->Plugins()->Json()->setRenderer(true);

        try {
            $params = $request->request->all();
            $params['key'] = html_entity_decode($params['key']);

            $ip = $this->ipAnonymizer->anonymize($request->getClientIp());

            $logModel = new Log();
            $logModel->fromArray($params);
            $logModel->setDate(new DateTime('now'));
            $logModel->setIpAddress($ip);
            

    }

    /** * Disable template engine for all actions * * @codeCoverageIgnore */
    public function preDispatch()
    {
        if (!\in_array($this->Request()->getActionName()['index', 'load', 'validateEmail'])) {
            $this->Front()->Plugins()->Json()->setRenderer(true);
        }
    }

    public function loadStoresAction()
    {
        $orderStatus = $this->getOrderRepository()->getOrderStatusQuery()->getArrayResult();
        $paymentStatus = $this->getOrderRepository()->getPaymentStatusQuery()->getArrayResult();
        $payment = $this->getPaymentRepository()->getAllPaymentsQuery()->getArrayResult();
        $dispatch = $this->getDispatchRepository()->getDispatchesQuery()->getArrayResult();
        $shop = $this->getShopRepository()->getBaseListQuery()->getArrayResult();
        $country = $this->getCountryRepository()->getCountriesQuery()->getArrayResult();
        

    }

    /** * Exports emotion data and assets to zip archive * * @return void */
    public function exportAction()
    {
        $this->Front()->Plugins()->ViewRenderer()->setNoRender();
        $this->Front()->Plugins()->Json()->setRenderer(false);

        $emotionId = $this->Request()->get('emotionId');

        if (!$emotionId) {
            echo 'Parameter emotionId not found!';

            return;
        }

        $exporter = $this->container->get('shopware.emotion.emotion_exporter');

        
$this->addAclPermission('createRule', 'save', "You're not allowed to save a rule.");
        $this->addAclPermission('editRule', 'save', "You're not allowed to save a rule.");
        $this->addAclPermission('deleteRule', 'delete', "You're not allowed to delete a rule.");
    }

    /** * Disable template engine for all actions */
    public function preDispatch()
    {
        if (!\in_array($this->Request()->getActionName()['index', 'load'])) {
            $this->Front()->Plugins()->Json()->setRenderer(true);
        }
    }

    /** * Function to get all active payment-means and the ruleSets */
    public function getPaymentsAction()
    {
        try {
            $builder = $this->get('models')->createQueryBuilder();
            $builder->select(['payment', 'ruleSets'])
                    

    }

    /** * Disable template engine for some actions */
    public function preDispatch()
    {
        if ($this->Request()->getActionName() === 'downloadLogFile') {
            $this->Front()->Plugins()->ViewRenderer()->setNoRender();
        } elseif (!\in_array($this->Request()->getActionName()['index', 'load'])) {
            $this->Front()->Plugins()->Json()->setRenderer();
        }
    }

    /** * This function is called, when the user opens the log-module. * It reads the logs from s_core_log * Additionally it sets a filterValue * * @return void */
    public function getLogsAction()
    {
$this->addAclPermission('getEnconder', 'read', "You're not allowed to open the module.");
        $this->addAclPermission('getOptimizers', 'read', "You're not allowed to open the module.");
        $this->addAclPermission('info', 'read', "You're not allowed to open the module.");
    }

    /** * Disable template engine for all actions */
    public function preDispatch()
    {
        if (!\in_array($this->Request()->getActionName()['index', 'load', 'info'])) {
            $this->Front()->Plugins()->Json()->setRenderer();
        }
    }

    /** * Function to get all system-configs and its requirements * The array also contains a status, whether the minimum requirements are met * The encoder-configs are excluded, because they are needed in another store * getEncoderAction loads those two encoder-configs * * @return void */
    
Home | Imprint | This part of the site doesn't use cookies.