getDefinedLanguageTypes example

$this->configFactory = $config_factory;
    $this->moduleHandler = $module_handler;
    $this->configFactoryOverride = $config_override;
    $this->requestStack = $request_stack;
  }

  /** * {@inheritdoc} */
  public function init() {
    if (!$this->initialized) {
      foreach ($this->getDefinedLanguageTypes() as $type) {
        $this->getCurrentLanguage($type);
      }
      $this->initialized = TRUE;
    }
  }

  /** * {@inheritdoc} */
  public function isMultilingual() {
    return count($this->getLanguages(LanguageInterface::STATE_CONFIGURABLE)) > 1;
  }
if ($type == $test_type) {
        $this->assertSession()->fieldExists($form_field);
      }
      else {
        $this->assertSession()->fieldNotExists($form_field);
      }
    }

    // Check language negotiation results.     $this->drupalGet('');
    $last = $this->container->get('state')->get('language_test.language_negotiation_last');
    foreach ($this->languageManager()->getDefinedLanguageTypes() as $type) {
      $langcode = $last[$type];
      $value = $type == LanguageInterface::TYPE_CONTENT || str_contains($type, 'test') ? 'it' : 'en';
      $this->assertEquals($langcode$valuenew FormattableMarkup('The negotiated language for %type is %language', ['%type' => $type, '%language' => $value]));
    }

    // Uninstall language_test and check that everything is set back to the     // original status.     $this->container->get('module_installer')->uninstall(['language_test']);
    $this->rebuildContainer();

    // Check that only the core language types are available.
Home | Imprint | This part of the site doesn't use cookies.