本文整理汇总了PHP中Drupal\Core\Language\LanguageManagerInterface::getDefaultLockedLanguages方法的典型用法代码示例。如果您正苦于以下问题:PHP LanguageManagerInterface::getDefaultLockedLanguages方法的具体用法?PHP LanguageManagerInterface::getDefaultLockedLanguages怎么用?PHP LanguageManagerInterface::getDefaultLockedLanguages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Language\LanguageManagerInterface
的用法示例。
在下文中一共展示了LanguageManagerInterface::getDefaultLockedLanguages方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
function setUp()
{
parent::setUp();
$this->languageManager = $this->container->get('language_manager');
$this->installEntitySchema('entity_test_rev');
$this->installEntitySchema('entity_test_mul');
$this->installEntitySchema('entity_test_mulrev');
$this->installConfig(array('language'));
// Create the test field.
entity_test_install();
// Enable translations for the test entity type.
$this->state->set('entity_test.translation', TRUE);
// Create a translatable test field.
$this->field_name = drupal_strtolower($this->randomMachineName() . '_field_name');
// Create an untranslatable test field.
$this->untranslatable_field_name = drupal_strtolower($this->randomMachineName() . '_field_name');
// Create field instances in all entity variations.
foreach (entity_test_entity_types() as $entity_type) {
entity_create('field_storage_config', array('name' => $this->field_name, 'entity_type' => $entity_type, 'type' => 'text', 'cardinality' => 4))->save();
entity_create('field_instance_config', array('field_name' => $this->field_name, 'entity_type' => $entity_type, 'bundle' => $entity_type, 'translatable' => TRUE))->save();
$this->instance[$entity_type] = entity_load('field_instance_config', $entity_type . '.' . $entity_type . '.' . $this->field_name);
entity_create('field_storage_config', array('name' => $this->untranslatable_field_name, 'entity_type' => $entity_type, 'type' => 'text', 'cardinality' => 4))->save();
entity_create('field_instance_config', array('field_name' => $this->untranslatable_field_name, 'entity_type' => $entity_type, 'bundle' => $entity_type, 'translatable' => FALSE))->save();
}
// Create the default languages.
$default_language = language_save($this->languageManager->getDefaultLanguage());
$languages = $this->languageManager->getDefaultLockedLanguages($default_language->weight);
foreach ($languages as $language) {
language_save($language);
}
// Create test languages.
$this->langcodes = array();
for ($i = 0; $i < 3; ++$i) {
$language = new Language(array('id' => 'l' . $i, 'name' => $this->randomString(), 'weight' => $i));
$this->langcodes[$i] = $language->id;
language_save($language);
}
}