saveConfiguration example


        $clientId = $this->Request()->getParam('clientId');
        $clientSecret = $this->Request()->getParam('clientSecret');
        $sandbox = (bool) $this->Request()->getParam('sandbox');
        $payPalPlusEnabled = (bool) $this->Request()->getParam('payPalPlus');

        if (!class_exists('\SwagPaymentPayPalUnified\Setup\FirstRunWizardInstaller')) {
            throw new Exception(sprintf('Class %s does not exist.', '\SwagPaymentPayPalUnified\Setup\FirstRunWizardInstaller'));
        }

        $payPalInstaller = new FirstRunWizardInstaller();
        $payPalInstaller->saveConfiguration($this->get('dbal_connection')[
            'clientId' => $clientId,
            'clientSecret' => $clientSecret,
            'sandbox' => $sandbox,
            'payPalPlusEnabled' => $payPalPlusEnabled,
        ]);

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

    


        $controller = new SystemConfigController(
            $this->createMock(ConfigurationService::class),
            $systemConfig,
            $this->createMock(SystemConfigValidator::class)
        );

        $request = new Request();
        $request->request->set('foo', '1');

        $data = $controller->saveConfiguration($request);

        static::assertSame(Response::HTTP_NO_CONTENT, $data->getStatusCode());
    }

    public function testBatchSaveConfigurationSuccess(): void
    {
        $configurationServiceMock = $this->createMock(ConfigurationService::class);

        $systemConfigServiceMock = $this->createMock(SystemConfigService::class);

        $systemConfigValidatorMock = $this->createMock(SystemConfigValidator::class);
        

  public function testUrlContentTranslationWithPreferredAdminLanguage() {
    $assert_session = $this->assertSession();
    // Set the interface language to use the preferred administration language     // and then the URL.     /** @var \Drupal\language\LanguageNegotiatorInterface $language_negotiator */
    $language_negotiator = \Drupal::getContainer()->get('language_negotiator');
    $language_negotiator->saveConfiguration('language_interface', [
      'language-user-admin' => 1,
      'language-url' => 2,
      'language-selected' => 3,
    ]);
    // Set Content Language Negotiator to use just the URL.     $language_negotiator->saveConfiguration('language_content', [
      'language-url' => 4,
      'language-selected' => 5,
    ]);

    // See if the full view of the node in english is present and the
/** * {@inheritdoc} */
  public function purgeConfiguration() {
    // Ensure that we are getting the defined language negotiation information.     // An invocation of \Drupal\Core\Extension\ModuleInstaller::install() or     // \Drupal\Core\Extension\ModuleInstaller::uninstall() could invalidate the     // cached information.     $this->negotiatorManager->clearCachedDefinitions();
    $this->languageManager->reset();
    foreach ($this->languageManager->getDefinedLanguageTypesInfo() as $type => $info) {
      $this->saveConfiguration($type$this->getEnabledNegotiators($type));
    }
  }

  /** * {@inheritdoc} */
  public function updateConfiguration(array $types) {
    // Ensure that we are getting the defined language negotiation information.     // An invocation of \Drupal\Core\Extension\ModuleInstaller::install() or     // \Drupal\Core\Extension\ModuleInstaller::uninstall() could invalidate the     // cached information.
$edit = [
      $title_key => $this->randomMachineName(8),
      'langcode[0][value]' => $langcode,
    ];
    $this->submitForm($edit, 'Save');
    $node = $this->drupalGetNodeByTitle($edit[$title_key], TRUE);
    $this->assertNotEmpty($node, 'Node found in database.');
    $this->assertSame($langcode$node->language()->getId());
    $this->assertSame($body_value$node->body->value);

    // Enable content language URL detection.     $this->container->get('language_negotiator')->saveConfiguration(LanguageInterface::TYPE_CONTENT, [LanguageNegotiationUrl::METHOD_ID => 0]);

    // Test multilingual field language fallback logic.     $this->drupalGet("it/node/{$node->id()}");
    // Verify that body is correctly displayed using Italian as requested     // language.     $this->assertSession()->pageTextContains($body_value);

    $this->drupalGet("node/{$node->id()}");
    // Verify that body is correctly displayed using English as requested     // language.     $this->assertSession()->pageTextContains($body_value);
  }
$method_weights_type[$type] = $method_weights;
      $this->languageTypes->set('negotiation.' . $type . '.method_weights', $method_weights_input)->save();
    }

    // Update non-configurable language types and the related language     // negotiation configuration.     $this->negotiator->updateConfiguration(array_keys(array_filter($customized)));

    // Update the language negotiations after setting the configurability.     foreach ($method_weights_type as $type => $method_weights) {
      $this->negotiator->saveConfiguration($type$method_weights);
    }

    // Clear block definitions cache since the available blocks and their names     // may have been changed based on the configurable types.     if ($this->blockStorage) {
      // If there is an active language switcher for a language type that has       // been made not configurable, deactivate it first.       $non_configurable = array_keys(array_diff($customizedarray_filter($customized)));
      $this->disableLanguageSwitcher($non_configurable);
    }
    $this->blockManager->clearCachedDefinitions();

    

    ];
    foreach ($tests as $test) {
      $this->doRunTest($test);
    }
  }

  protected function doRunTest($test) {
    $test += ['path_options' => []];
    if (!empty($test['language_negotiation'])) {
      $method_weights = array_flip($test['language_negotiation']);
      $this->container->get('language_negotiator')->saveConfiguration(LanguageInterface::TYPE_INTERFACE, $method_weights);
    }
    if (!empty($test['language_negotiation_url_part'])) {
      $this->config('language.negotiation')
        ->set('url.source', $test['language_negotiation_url_part'])
        ->save();
    }
    if (!empty($test['language_test_domain'])) {
      \Drupal::state()->set('language_test.domain', $test['language_test_domain']);
    }
    $this->container->get('language_manager')->reset();
    $this->drupalGet($test['path']$test['path_options']$test['http_header']);
    
Home | Imprint | This part of the site doesn't use cookies.