本文整理汇总了PHP中Drupal\language\Entity\ConfigurableLanguage::save方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigurableLanguage::save方法的具体用法?PHP ConfigurableLanguage::save怎么用?PHP ConfigurableLanguage::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\language\Entity\ConfigurableLanguage
的用法示例。
在下文中一共展示了ConfigurableLanguage::save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetLanguages
public function testGetLanguages()
{
$this->installSchema('locale', ['locales_source', 'locales_target', 'locales_location']);
$default_language = new ConfigurableLanguage(['label' => $this->randomMachineName(), 'id' => 'default', 'weight' => 0], 'configurable_language');
$default_language->save();
// Set new default language.
\Drupal::service('language.default')->set($default_language);
\Drupal::service('string_translation')->setDefaultLangcode($default_language->getId());
$languages = \Drupal::service('language_manager')->getLanguages(LanguageInterface::STATE_ALL);
$this->assertEqual(['default', 'und', 'zxx'], array_keys($languages));
$configurableLanguage = new ConfigurableLanguage(['label' => $this->randomMachineName(), 'id' => 'test', 'weight' => 1], 'configurable_language');
// Simulate a configuration sync by setting the flag otherwise the locked
// language weights would be updated whilst saving.
// @see \Drupal\language\Entity\ConfigurableLanguage::postSave()
$configurableLanguage->setSyncing(TRUE)->save();
$languages = \Drupal::service('language_manager')->getLanguages(LanguageInterface::STATE_ALL);
$this->assertEqual(['default', 'test', 'und', 'zxx'], array_keys($languages));
}