updateShop example


class ShopConfigurationServiceTest extends TestCase
{
    use IntegrationTestBehaviour;

    public function testUpdateShop(): void
    {
        $service = new ShopConfigurationService();

        $connection = $this->getContainer()->get(Connection::class);

        $service->updateShop([
            'name' => 'test-shop',
            'locale' => 'de-DE',
            'currency' => 'USD',
            'additionalCurrencies' => ['EUR', 'CHF'],
            'country' => 'DEU',
            'email' => 'test@test.com',
            'host' => 'localhost',
            'schema' => 'https',
            'basePath' => '/shop',
            'blueGreenDeployment' => true,
        ]$connection);

        
'country' => (string) $request->request->get('config_shop_country'),
                'email' => (string) $request->request->get('config_mail'),
                'host' => (string) $_SERVER['HTTP_HOST'],
                'schema' => $schema,
                'basePath' => str_replace('/index.php', '', (string) $_SERVER['SCRIPT_NAME']),
                'blueGreenDeployment' => (bool) $session->get(BlueGreenDeploymentService::ENV_NAME),
            ];

            try {
                $this->envConfigWriter->writeConfig($connectionInfo$shop);

                $this->shopConfigurationService->updateShop($shop$connection);
                $this->adminConfigurationService->createAdmin($adminUser$connection);

                $session->remove(DatabaseConnectionInformation::class);
                $session->set('ADMIN_USER', $adminUser);

                return $this->redirectToRoute('installer.finish');
            } catch (\Exception $e) {
                $error = $e->getMessage();
            }
        }

        
$locale = $_SESSION['parameters']['c_config_shop_language'] ?: 'de_DE';

        $shopService = new ShopService($db$container['uniqueid.generator']);
        $currencyService = new CurrencyService($db);
        $adminService = new AdminService($db);
        $localeSettingsService = new LocaleSettingsService($db$container);

        $hasErrors = false;
        try {
            $adminService->createAdmin($adminUser);
            $adminService->addWidgets($adminUser);
            $shopService->updateShop($shop);
            $currencyService->updateCurrency($shop);
            $shopService->updateConfig($shop);
            $localeSettingsService->updateLocaleSettings($locale);
        } catch (\Exception $e) {
            $hasErrors = true;
            $app->view()->setData('error', $e->getMessage());
        }

        if (!$hasErrors) {
            $app->redirect($app->urlFor('finalize'));
        }
    }
return 1;
            }
        }

        $adminUser = new AdminUser();
        if (!$input->getOption('skip-admin-creation')) {
            $adminUser = $this->getAdminInfoFromArgs($input$adminUser);
            $adminUser = $this->getAdminInfoFromInteractiveShell($adminUser);
        }

        $shopService = new ShopService($conn$container['uniqueid.generator']);
        $shopService->updateShop($shop);
        $shopService->updateConfig($shop);

        $currencyService = new CurrencyService($conn);
        $currencyService->updateCurrency($shop);

        $localeService = new LocaleSettingsService($conn$container);
        $localeService->updateLocaleSettings($shop->locale);

        if (!$input->getOption('skip-admin-creation')) {
            $adminService = new AdminService($conn);
            $adminService->createAdmin($adminUser);
            
Home | Imprint | This part of the site doesn't use cookies.