Snippets example


    protected function getPerformanceCheckData()
    {
        $descriptionPHPVersion = '';
        if (version_compare(PHP_VERSION, self::PHP_RECOMMENDED_VERSION, '>=')) {
            $validPHPVersion = self::PERFORMANCE_VALID;
        } elseif (version_compare(PHP_VERSION, self::PHP_MINIMUM_VERSION, '>=')) {
            $validPHPVersion = self::PERFORMANCE_WARNING;
            $descriptionPHPVersion = Shopware()->Snippets()->getNamespace('backend/performance/main')
                ->get('cache/php_version/description_eol');
        } else {
            $validPHPVersion = self::PERFORMANCE_INVALID;
        }

        return [
            [
                'id' => 1,
                'name' => Shopware()->Snippets()->getNamespace('backend/performance/main')->get('cache/apc'),
                'value' => \extension_loaded('apcu'),
                'valid' => \extension_loaded('apcu') === true && \ini_get('apc.enabled') ? self::PERFORMANCE_VALID : self::PERFORMANCE_INVALID,
            ],

    /** * @var Repository */
    protected $repository;

    /** * Returns available mails */
    public function getMailsAction()
    {
        $snippet = Shopware()->Snippets()->getNamespace('backend/mail/view/navigation');

        // If id is provided return a single mail instead of a collection         $id = (int) $this->Request()->getParam('id');
        if ($id !== 0) {
            $this->getSingleMail($id);

            return;
        }

        /** @var Mail[] $mails */
        $mails = $this->getRepository()->findAll();

        

    public function init()
    {
        parent::init();
        if (self::$testRepository !== null) {
            $this->repository = self::$testRepository;
        } else {
            $this->repository = $this->get('models')->getRepository(Banner::class);
        }
        $this->namespace = Shopware()->Snippets()->getNamespace('backend/banner/banner');
    }

    /** * Basis Method to gather banner information. * * If the parameter is set true, every banner will be counted as shown */
    public function getAllBanners()
    {
        $params = $this->Request()->getParams();
        $filter = (empty($params['categoryId'])) ? '' : $params['categoryId'];

        
return;
        }

        $sErrorFlag = [];
        $sErrorMessages = [];

        $accountMode = (int) $this->View()->getAssign('sUserData')['additional']['user']['accountmode'];

        if ($dispatch === null && Shopware()->Config()->get('premiumshippingnoorder') === true && !$this->getDispatches($payment) && $accountMode === 0) {
            $sErrorFlag['sDispatch'] = true;
            $sErrorMessages[] = Shopware()->Snippets()->getNamespace('frontend/checkout/error_messages')
                ->get('ShippingPaymentSelectShipping', 'Please select a shipping method');
        }
        if ($payment === null) {
            $sErrorFlag['payment'] = true;
            $sErrorMessages[] = Shopware()->Snippets()->getNamespace('frontend/checkout/error_messages')
                ->get('ShippingPaymentSelectPayment', 'Please select a payment method');
        }

        // If any basic info is missing, return error messages         if (!empty($sErrorFlag) || !empty($sErrorMessages)) {
            $this->View()->assign('sErrorFlag', $sErrorFlag);
            
'char' => $this->_order['templatechar'],
        ], ArrayObject::ARRAY_AS_PROPS);
    }

    /** * Get all information from a certain order (model) * * @return void */
    public function processOrder()
    {
        $snippetManager = Shopware()->Snippets();
        $modelManager = Shopware()->Models();
        $orderLocale = null;

        if ($modelManager !== null) {
            $orderLocale = $modelManager->find(
                ShopLocale::class,
                $this->_order['language']
            );
        }

        if ($orderLocale !== null) {
            

        if (Shopware()->Config()->get('sepaShowBankName') && Shopware()->Config()->get('sepaRequireBankName') && (empty($paymentData['sSepaBankName']) || trim($paymentData['sSepaBankName']) === '')) {
            $sErrorFlag['sSepaBankName'] = true;
        }

        $sErrorFlag = Shopware()->Container()->get('events')->filter('Sepa_Payment_Method_Validate_Data_Required', $sErrorFlag[
            'subject' => $this,
            'paymentData' => $paymentData,
        ]);

        if (\count($sErrorFlag)) {
            $sErrorMessages[] = Shopware()->Snippets()->getNamespace('frontend/account/internalMessages')->get('ErrorFillIn', 'Please fill in all red fields');
        }

        if (isset($paymentData['sSepaIban']) && !$this->validateIBAN((string) $paymentData['sSepaIban'])) {
            $sErrorMessages[] = Shopware()->Snippets()->getNamespace('frontend/plugins/payment/sepa')->get('ErrorIBAN', 'Invalid IBAN');
            $sErrorFlag['sSepaIban'] = true;
        }

        if (\count($sErrorMessages)) {
            return [
                'sErrorFlag' => $sErrorFlag,
                'sErrorMessages' => $sErrorMessages,
            ];
foreach ($fields as $field) {
            $value = $paymentData[$field] ?? '';
            $value = trim($value);

            if (empty($value)) {
                $sErrorFlag[$field] = true;
            }
        }

        if (\count($sErrorFlag)) {
            $sErrorMessages[] = Shopware()->Snippets()->getNamespace('frontend/account/internalMessages')
                ->get('ErrorFillIn', 'Please fill in all red fields');

            return [
                'sErrorFlag' => $sErrorFlag,
                'sErrorMessages' => $sErrorMessages,
            ];
        }

        return [];
    }

    

    private function isProductPosition(Detail $orderDetailModel): bool
    {
        return $orderDetailModel->getMode() === CartPositionsMode::PRODUCT;
    }

    /** * Helper function to get the correct translation */
    private function translateMessage(string $name, string $default): string
    {
        $namespace = Shopware()->Snippets()->getNamespace('backend/canceled_order/controller/main');

        return $namespace->get($name$default);
    }

    private function getStartDate(): string
    {
        $timeStamp = (int) mktime(0, 0, 0, 1, 1, (int) date('Y'));

        return $this->Request()->getParam('fromDate', date('Y-m-d', $timeStamp));
    }
}
$this->View()->assign(['success' => true, 'data' => $data, 'total' => 1]);
    }

    /** * Method to define acl dependencies in backend controllers * <code> * $this->addAclPermission("name_of_action_with_action_prefix","name_of_assigned_privilege","optionally error message"); * </code> */
    protected function initAcl()
    {
        $namespace = Shopware()->Snippets()->getNamespace('backend/supplier');

        $this->addAclPermission('getSuppliersAction', 'read', $namespace->get('no_list_rights', 'Read access denied.'));
        $this->addAclPermission('deleteSupplierAction', 'delete', $namespace->get('no_list_rights', 'Delete access denied.'));
        $this->addAclPermission('updateSupplierAction', 'update', $namespace->get('no_update_rights', 'Update access denied.'));
        $this->addAclPermission('createSupplierAction', 'create', $namespace->get('no_create_rights', 'Create access denied.'));
    }

    /** * Internal helper function to get access to the form repository. */
    private function getRepository(): Repository
    {
/** * Helper function to get the correct translation * * @param string $name * @param string $default * * @return string */
    private function translateMessage($name$default = null)
    {
        $namespace = Shopware()->Snippets()->getNamespace('backend/newsletter_manager/main');

        return $namespace->get($name$default);
    }
}
$this->View()->assign([
            'success' => true,
            'data' => $result,
            'total' => $totalResult,
        ]);
    }

    public function getAvailableCaptchasAction()
    {
        $captchaRepository = $this->get('shopware.captcha.repository');
        $namespace = $namespace = Shopware()->Snippets()->getNamespace('backend/captcha/display_names');
        $availableCaptchas = $captchaRepository->getList();
        $result = [];

        foreach ($availableCaptchas as $captcha) {
            $result[] = [
                'id' => $captcha->getName(),
                'displayname' => $namespace->get($captcha->getName()ucfirst(strtolower($captcha->getName()))),
            ];
        }

        $totalResult = \count($availableCaptchas);

        
Shopware_Components_Snippet_Manager $snippetManager = null,
        ?Shopware_Components_Config $config = null,
        ?Enlight_Components_Session_Namespace $session = null,
        ?Enlight_Controller_Front $front = null,
        ?Shopware_Components_Modules $moduleManager = null,
        ?sSystem $systemModule = null,
        ?ContextServiceInterface $contextService = null,
        ?AdditionalTextServiceInterface $additionalTextService = null
    ) {
        $this->db = $db ?: Shopware()->Db();
        $this->eventManager = $eventManager ?: Shopware()->Events();
        $this->snippetManager = $snippetManager ?: Shopware()->Snippets();
        $this->config = $config ?: Shopware()->Config();
        $this->session = $session ?: Shopware()->Session();
        $this->front = $front ?: Shopware()->Front();
        $this->moduleManager = $moduleManager ?: Shopware()->Modules();
        $this->sSYSTEM = $systemModule ?: Shopware()->System();

        $this->contextService = $contextService;
        $this->additionalTextService = $additionalTextService;
        $this->connection = Shopware()->Container()->get(Connection::class);

        if ($this->contextService === null) {
            
/** * @deprecated - Will be private in Shopware 5.8 * Send a mail asking the customer, if he actually wants to reset his password * * @param string $email * * @return array{sErrorMessages?: array<string>, sErrorFlag?: array{email?: true, sCaptcha?: true}} */
    public function sendResetPasswordConfirmationMail($email)
    {
        $snippets = Shopware()->Snippets()->getNamespace('frontend/account/password');
        if ($this->config->get(self::CONFIG_PASSWORD_RESET_CAPTCHA) !== NoCaptcha::CAPTCHA_METHOD) {
            if (!empty($this->config->get('CaptchaColor'))) {
                if (!$this->captchaValidator->validateByName($this->config->get(self::CONFIG_PASSWORD_RESET_CAPTCHA)$this->Request())) {
                    return [
                        'sErrorMessages' => [$snippets->get('captchaInvalid')],
                        'sErrorFlag' => ['sCaptcha' => true],
                    ];
                }
            }
        }

        
$shopId = is_numeric($order['language']) ? $order['language'] : $order['subshopID'];
        // The (sub-)shop might be inactive by now, so that's why we use `getById` instead of `getActiveById`         $shop = $repository->getById($shopId);
        if ($shop === null) {
            throw new ModelNotFoundException(Shop::class$shopId);
        }
        Shopware()->Container()->get(ShopRegistrationServiceInterface::class)->registerShop($shop);

        $dispatch = Shopware()->Modules()->Admin()->sGetDispatchTranslation($dispatch);
        $payment = Shopware()->Modules()->Admin()->sGetPaymentTranslation(['id' => $order['paymentID']]);

        $order['status_description'] = Shopware()->Snippets()->getNamespace('backend/static/order_status')->get(
            $order['status_name'],
            $order['status_description']
        );
        $order['cleared_description'] = Shopware()->Snippets()->getNamespace('backend/static/payment_status')->get(
            $order['cleared_name'],
            $order['cleared_description']
        );

        if (!empty($payment['description'])) {
            $order['payment_description'] = $payment['description'];
        }

        
$this->_elements[$id]['value'] = $element['value'];
                    } catch (InvalidOrderNumberException $exception) {
                        // Explicit empty catch                     } catch (TypeError $exception) {
                        // Explicit empty catch                     }
                }

                if ($element['name'] === 'inquiry' && !empty($this->Request()->sInquiry)) {
                    switch ($this->Request()->sInquiry) {
                        case 'basket':
                            $text = Shopware()->Snippets()->getNamespace('frontend/detail/comment')->get('InquiryTextBasket');
                            $getBasket = Shopware()->Modules()->Basket()->sGetBasket();
                            foreach ($getBasket[CartKey::POSITIONS] ?? [] as $basketRow) {
                                if (empty($basketRow['modus'])) {
                                    $text .= sprintf(
                                        "\n%s x %s (%s) - %s %s",
                                        $basketRow['quantity'],
                                        $basketRow['articlename'],
                                        $basketRow['ordernumber'],
                                        $basketRow['price'],
                                        Shopware()->System()->sCurrency['currency']
                                    );
                                }
Home | Imprint | This part of the site doesn't use cookies.