translateDocuments example

->addOrderBy((array) $this->Request()->getParam('sort', []))
            ->setFirstResult($this->Request()->getParam('start', 0))
            ->setMaxResults($this->Request()->getParam('limit', 250));

        $query = $builder->getQuery();
        $total = $modelManager->getQueryCount($query);
        $data = $query->getArrayResult();

        // translate the document names         /** @var Shopware_Components_Translation $translationComponent */
        $translationComponent = $this->get(Shopware_Components_Translation::class);
        $data = $translationComponent->translateDocuments($data);

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

    public function getLandingPagesAction(Request $request): void
    {
        $modelManager = $this->container->get(ModelManager::class);
        $emotionRepository = $modelManager->getRepository(Emotion::class);

        $builder = $emotionRepository->createQueryBuilder('emotion');

        
if (\array_key_exists('documents', $order)) {
                foreach ($order['documents'] as $documentIndex => $document) {
                    if (!$document['type']) {
                        continue;
                    }
                    $documentTypes[$document['type']['id']] = $document['type'];
                }
            }
        }

        // Translate the objects         $translatedDocumentTypes = $this->translateDocuments($documentTypes$language$fallback);
        $translatedDispatchMethods = $this->translateDispatchMethods($dispatchMethods$language$fallback);
        $translatedPaymentMethods = $this->translatePaymentMethods($paymentMethods$language$fallback);

        // Save the translated objects         foreach ($orders as &$order) {
            $orderDocuments = isset($order['documents']) && \is_array($order['documents']) ? $order['documents'] : [];

            for ($documentCounter = 0, $orderDocumentsCount = \count($orderDocuments)$documentCounter < $orderDocumentsCount; ++$documentCounter) {
                $type = $orderDocuments[$documentCounter]['type'];
                $order['documents'][$documentCounter]['type'] = $translatedDocumentTypes[$type['id']];
            }

            


        $shops = $this->getShopRepository()->getBaseListQuery()->getArrayResult();
        $countries = $this->getCountryRepository()->getCountriesQuery(null, $countriesSort)->getArrayResult();
        $payments = $this->getPaymentRepository()->getAllPaymentsQuery()->getArrayResult();
        $dispatches = $this->getDispatchRepository()->getDispatchesQuery()->getArrayResult();
        $documentTypes = $this->getRepository()->getDocumentTypesQuery()->getArrayResult();

        // Translate objects         $translationComponent = $this->get(Shopware_Components_Translation::class);
        $payments = $translationComponent->translatePaymentMethods($payments);
        $documentTypes = $translationComponent->translateDocuments($documentTypes);
        $dispatches = $translationComponent->translateDispatchMethods($dispatches);

        $this->View()->assign([
            'success' => true,
            'data' => [
                'orderStatus' => $orderState,
                'paymentStatus' => $paymentState,
                'shops' => $shops,
                'countries' => $countries,
                'payments' => $payments,
                'dispatches' => $dispatches,
                
Home | Imprint | This part of the site doesn't use cookies.