本文整理匯總了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);
}
}