本文整理汇总了PHP中Drupal\language\Entity\ConfigurableLanguage类的典型用法代码示例。如果您正苦于以下问题:PHP ConfigurableLanguage类的具体用法?PHP ConfigurableLanguage怎么用?PHP ConfigurableLanguage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConfigurableLanguage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: testWeight
/**
* @covers ::getWeight
* @covers ::setWeight
*/
public function testWeight()
{
// The weight, an integer. Used to order languages with larger positive
// weights sinking items toward the bottom of lists.
$configurableLanguage = new ConfigurableLanguage(array('weight' => -5), 'configurable_language');
$this->assertEquals($configurableLanguage->getWeight(), -5);
$this->assertEquals($configurableLanguage->setWeight(13)->getWeight(), 13);
}
开发者ID:ddrozdik,项目名称:dmaps,代码行数:12,代码来源:ConfigurableLanguageUnitTest.php
示例2: testName
/**
* Tests configurable language name methods.
*/
public function testName()
{
$name = $this->randomMachineName();
$language_code = $this->randomMachineName(2);
$configurableLanguage = new ConfigurableLanguage(array('label' => $name, 'id' => $language_code), 'configurable_language');
$this->assertEqual($configurableLanguage->getName(), $name);
$this->assertEqual($configurableLanguage->setName('Test language')->getName(), 'Test language');
}
开发者ID:papillon-cendre,项目名称:d8,代码行数:11,代码来源:ConfigurableLanguageTest.php
示例3: testContentTranslationForm
/**
* Tests content translation form translatability constraints messages.
*/
public function testContentTranslationForm()
{
$this->loginAsAdmin(['administer languages', 'administer content translation', 'create content translations', 'translate any entity']);
// Check warning message is displayed.
$this->drupalGet('admin/config/regional/content-language');
$this->assertText('(* unsupported) Paragraphs fields do not support translation.');
$this->addParagraphedContentType('paragraphed_test', 'paragraphs_field');
// Check error message is displayed.
$this->drupalGet('admin/config/regional/content-language');
$this->assertText('(* unsupported) Paragraphs fields do not support translation.');
$this->assertRaw('<div class="messages messages--error');
// Add a second language.
ConfigurableLanguage::create(['id' => 'de'])->save();
// Enable translation for paragraphed content type.
$edit = ['entity_types[node]' => TRUE, 'settings[node][paragraphed_test][translatable]' => TRUE, 'settings[node][paragraphed_test][fields][paragraphs_field]' => FALSE];
$this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration'));
// Check content type field management warning.
$this->drupalGet('admin/structure/types/manage/paragraphed_test/fields/node.paragraphed_test.paragraphs_field');
$this->assertText('Paragraphs fields do not support translation.');
// Make the paragraphs field translatable.
$edit = ['entity_types[node]' => TRUE, 'settings[node][paragraphed_test][translatable]' => TRUE, 'settings[node][paragraphed_test][fields][paragraphs_field]' => TRUE];
$this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration'));
// Check content type field management error.
$this->drupalGet('admin/structure/types/manage/paragraphed_test/fields/node.paragraphed_test.paragraphs_field');
$this->assertText('Paragraphs fields do not support translation.');
$this->assertRaw('<div class="messages messages--error');
}
开发者ID:eric-shell,项目名称:eric-shell-d8,代码行数:30,代码来源:ParagraphsConfigTest.php
示例4: setUp
function setUp()
{
parent::setUp();
// Add two new languages.
ConfigurableLanguage::createFromLangcode('fr')->save();
ConfigurableLanguage::createFromLangcode('es')->save();
// Set up term names.
$this->termNames = array('en' => 'Food in Paris', 'es' => 'Comida en Paris', 'fr' => 'Nouriture en Paris');
// Create a vocabulary.
$this->vocabulary = Vocabulary::create(['name' => 'Views testing tags', 'vid' => 'views_testing_tags']);
$this->vocabulary->save();
// Add a translatable field to the vocabulary.
$field = FieldStorageConfig::create(array('field_name' => 'field_foo', 'entity_type' => 'taxonomy_term', 'type' => 'text'));
$field->save();
FieldConfig::create(['field_name' => 'field_foo', 'entity_type' => 'taxonomy_term', 'label' => 'Foo', 'bundle' => 'views_testing_tags'])->save();
// Create term with translations.
$taxonomy = $this->createTermWithProperties(array('name' => $this->termNames['en'], 'langcode' => 'en', 'description' => $this->termNames['en'], 'field_foo' => $this->termNames['en']));
foreach (array('es', 'fr') as $langcode) {
$translation = $taxonomy->addTranslation($langcode, array('name' => $this->termNames[$langcode]));
$translation->description->value = $this->termNames[$langcode];
$translation->field_foo->value = $this->termNames[$langcode];
}
$taxonomy->save();
Views::viewsData()->clear();
ViewTestData::createTestViews(get_class($this), array('taxonomy_test_views'));
$this->container->get('router.builder')->rebuild();
}
开发者ID:eigentor,项目名称:tommiblog,代码行数:27,代码来源:TaxonomyFieldFilterTest.php
示例5: setUp
protected function setUp()
{
parent::setUp();
$this->installConfig(array('language'));
// Create another language beside English.
ConfigurableLanguage::create(array('id' => 'xx-lolspeak', 'label' => 'Lolspeak'))->save();
}
开发者ID:HakS,项目名称:drupal8_training,代码行数:7,代码来源:LanguageTestBase.php
示例6: testConfigTranslationImport
/**
* Test update changes configuration translations if enabled after language.
*/
public function testConfigTranslationImport()
{
$admin_user = $this->drupalCreateUser(array('administer modules', 'administer site configuration', 'administer languages', 'access administration pages', 'administer permissions'));
$this->drupalLogin($admin_user);
// Add a language. The Afrikaans translation file of locale_test_translate
// (test.af.po) has been prepared with a configuration translation.
ConfigurableLanguage::createFromLangcode('af')->save();
// Enable locale module.
$this->container->get('module_installer')->install(array('locale'));
$this->resetAll();
// Enable import of translations. By default this is disabled for automated
// tests.
$this->config('locale.settings')->set('translation.import_enabled', TRUE)->save();
// Add translation permissions now that the locale module has been enabled.
$edit = array('authenticated[translate interface]' => 'translate interface');
$this->drupalPostForm('admin/people/permissions', $edit, t('Save permissions'));
// Check and update the translation status. This will import the Afrikaans
// translations of locale_test_translate module.
$this->drupalGet('admin/reports/translations/check');
// Override the Drupal core translation status to be up to date.
// Drupal core should not be a subject in this test.
$status = locale_translation_get_status();
$status['drupal']['af']->type = 'current';
\Drupal::state()->set('locale.translation_status', $status);
$this->drupalPostForm('admin/reports/translations', array(), t('Update translations'));
// Check if configuration translations have been imported.
$override = \Drupal::languageManager()->getLanguageConfigOverride('af', 'system.maintenance');
$this->assertEqual($override->get('message'), 'Ons is tans besig met onderhoud op @site. Wees asseblief geduldig, ons sal binnekort weer terug wees.');
}
开发者ID:papillon-cendre,项目名称:d8,代码行数:32,代码来源:LocaleConfigTranslationImportTest.php
示例7: testSiteNameTranslation
/**
* Tests translating the site name.
*/
function testSiteNameTranslation()
{
$adminUser = $this->drupalCreateUser(array('administer site configuration', 'administer languages'));
$this->drupalLogin($adminUser);
// Add a custom language.
$langcode = 'xx';
$name = $this->randomMachineName(16);
$edit = array('predefined_langcode' => 'custom', 'langcode' => $langcode, 'label' => $name, 'direction' => LanguageInterface::DIRECTION_LTR);
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
\Drupal::languageManager()->getLanguageConfigOverride($langcode, 'system.site')->set('name', 'XX site name')->save();
$this->drupalLogout();
// The home page in English should not have the override.
$this->drupalGet('');
$this->assertNoText('XX site name');
// During path resolution the system.site configuration object is used to
// determine the front page. This occurs before language negotiation causing
// the configuration factory to cache an object without the correct
// overrides. We are testing that the configuration factory is
// re-initialised after language negotiation. Ensure that it applies when
// we access the XX front page.
// @see \Drupal\Core\PathProcessor::processInbound()
$this->drupalGet('xx');
$this->assertText('XX site name');
// Set the xx language to be the default language and delete the English
// language so the site is no longer multilingual and confirm configuration
// overrides still work.
$language_manager = \Drupal::languageManager()->reset();
$this->assertTrue($language_manager->isMultilingual(), 'The test site is multilingual.');
$this->config('system.site')->set('default_langcode', 'xx')->save();
ConfigurableLanguage::load('en')->delete();
$this->assertFalse($language_manager->isMultilingual(), 'The test site is monolingual.');
$this->drupalGet('xx');
$this->assertText('XX site name');
}
开发者ID:nstielau,项目名称:drops-8,代码行数:37,代码来源:ConfigLanguageOverrideWebTest.php
示例8: setUp
protected function setUp()
{
parent::setUp();
// Create and log in user.
$test_user = $this->drupalCreateUser(['access content', 'search content', 'use advanced search', 'administer nodes', 'administer languages', 'access administration pages', 'administer site configuration']);
$this->drupalLogin($test_user);
// Add a new language.
ConfigurableLanguage::createFromLangcode('es')->save();
// Set up times to be applied to the English and Spanish translations of the
// node create time, so that they are filtered in/out in the
// search_date_query_alter test module.
$created_time_en = new \DateTime('February 10 2016 10PM');
$created_time_es = new \DateTime('March 19 2016 10PM');
$default_format = filter_default_format();
$node = $this->drupalCreateNode(['title' => 'Node EN', 'type' => 'page', 'body' => ['value' => $this->randomMachineName(32), 'format' => $default_format], 'langcode' => 'en', 'created' => $created_time_en->format('U')]);
// Add Spanish translation to the node.
$translation = $node->addTranslation('es', ['title' => 'Node ES']);
$translation->body->value = $this->randomMachineName(32);
$translation->created->value = $created_time_es->format('U');
$node->save();
// Update the index.
$plugin = $this->container->get('plugin.manager.search')->createInstance('node_search');
$plugin->updateIndex();
search_update_totals();
}
开发者ID:systemick3,项目名称:systemick.co.uk,代码行数:25,代码来源:SearchDateIntervalTest.php
示例9: setUp
protected function setUp()
{
parent::setUp();
$permissions = array('access administration pages', 'administer site configuration');
$this->drupalLogin($this->drupalCreateUser($permissions));
ConfigurableLanguage::createFromLangcode('es')->save();
}
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:7,代码来源:AdminPathEntityConverterLanguageTest.php
示例10: setUp
protected function setUp()
{
parent::setUp();
// Set up an additional language.
$this->langcodes = array(language_default()->getId(), 'es');
ConfigurableLanguage::createFromLangcode('es')->save();
// Create a content type.
$this->bundle = $this->randomMachineName();
$this->contentType = $this->drupalCreateContentType(array('type' => $this->bundle));
// Enable translation for the current entity type and ensure the change is
// picked up.
content_translation_set_config('node', $this->bundle, 'enabled', TRUE);
drupal_static_reset();
\Drupal::entityManager()->clearCachedBundles();
\Drupal::service('router.builder')->rebuild();
// Add a translatable field to the content type.
entity_create('field_storage_config', array('field_name' => 'field_test_text', 'entity_type' => 'node', 'type' => 'text', 'cardinality' => 1, 'translatable' => TRUE))->save();
entity_create('field_config', array('entity_type' => 'node', 'field_name' => 'field_test_text', 'bundle' => $this->bundle, 'label' => 'Test text-field'))->save();
entity_get_form_display('node', $this->bundle, 'default')->setComponent('field_test_text', array('type' => 'text_textfield', 'weight' => 0))->save();
// Enable content translation.
$configuration = array('langcode' => language_default()->getId(), 'language_show' => TRUE);
language_save_default_configuration('node', $this->bundle, $configuration);
// Create a translator user.
$permissions = array('access contextual links', 'administer nodes', "edit any {$this->bundle} content", 'translate any entity');
$this->translator = $this->drupalCreateUser($permissions);
}
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:26,代码来源:ContentTranslationContextualLinksTest.php
示例11: setUp
protected 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 fields in all entity variations.
foreach (entity_test_entity_types() as $entity_type) {
entity_create('field_storage_config', array('field_name' => $this->field_name, 'entity_type' => $entity_type, 'type' => 'text', 'cardinality' => 4))->save();
entity_create('field_config', array('field_name' => $this->field_name, 'entity_type' => $entity_type, 'bundle' => $entity_type, 'translatable' => TRUE))->save();
$this->field[$entity_type] = entity_load('field_config', $entity_type . '.' . $entity_type . '.' . $this->field_name);
entity_create('field_storage_config', array('field_name' => $this->untranslatable_field_name, 'entity_type' => $entity_type, 'type' => 'text', 'cardinality' => 4))->save();
entity_create('field_config', array('field_name' => $this->untranslatable_field_name, 'entity_type' => $entity_type, 'bundle' => $entity_type, 'translatable' => FALSE))->save();
}
// Create the default languages.
$this->installConfig(array('language'));
// Create test languages.
$this->langcodes = array();
for ($i = 0; $i < 3; ++$i) {
$language = ConfigurableLanguage::create(array('id' => 'l' . $i, 'label' => $this->randomString(), 'weight' => $i));
$this->langcodes[$i] = $language->getId();
$language->save();
}
}
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:34,代码来源:EntityLanguageTestBase.php
示例12: setUp
protected function setUp()
{
parent::setUp();
$this->installEntitySchema('entity_test_mulrev');
$this->installEntitySchema('configurable_language');
ConfigurableLanguage::createFromLangcode('es')->save();
}
开发者ID:eigentor,项目名称:tommiblog,代码行数:7,代码来源:EntityNonRevisionableTranslatableFieldTest.php
示例13: setUp
function setUp()
{
parent::setUp();
// Create Page content type.
if ($this->profile != 'standard') {
$this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
}
// Add two new languages.
ConfigurableLanguage::createFromLangcode('fr')->save();
ConfigurableLanguage::createFromLangcode('es')->save();
// Make the body field translatable. The title is already translatable by
// definition.
$field_storage = FieldStorageConfig::loadByName('node', 'body');
$field_storage->translatable = TRUE;
$field_storage->save();
// Set up node titles.
$this->node_titles = array('en' => 'Food in Paris', 'es' => 'Comida en Paris', 'fr' => 'Nouriture en Paris');
// Create node with translations.
$node = $this->drupalCreateNode(array('title' => $this->node_titles['en'], 'langcode' => 'en', 'type' => 'page', 'body' => array(array('value' => $this->node_titles['en']))));
foreach (array('es', 'fr') as $langcode) {
$translation = $node->addTranslation($langcode, array('title' => $this->node_titles[$langcode]));
$translation->body->value = $this->node_titles[$langcode];
}
$node->save();
}
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:25,代码来源:NodeFieldFilterTest.php
示例14: setUp
public function setUp() {
parent::setup();
$this->installConfig(array('pathauto', 'taxonomy', 'system', 'node'));
$this->installEntitySchema('user');
$this->installEntitySchema('node');
$this->installEntitySchema('taxonomy_term');
ConfigurableLanguage::createFromLangcode('fr')->save();
$this->installSchema('node', array('node_access'));
$this->installSchema('system', array('url_alias', 'sequences', 'router'));
$type = NodeType::create(['type' => 'page']);
$type->save();
node_add_body_field($type);
$this->nodePattern = $this->createPattern('node', '/content/[node:title]');
$this->userPattern = $this->createPattern('user', '/users/[user:name]');
\Drupal::service('router.builder')->rebuild();
$this->currentUser = entity_create('user', array('name' => $this->randomMachineName()));
$this->currentUser->save();
}
开发者ID:AshishNaik021,项目名称:iimisac-d8,代码行数:26,代码来源:PathautoUnitTest.php
示例15: setUp
/**
* {@inheritdoc}
*/
public function setUp()
{
parent::setUp();
// Enable translation for the entity_test module.
\Drupal::state()->set('entity_test.translation', TRUE);
$this->installSchema('search_api', array('search_api_item', 'search_api_task'));
$this->installEntitySchema('entity_test_mul');
// Create the default languages.
$this->installConfig(array('language'));
$this->langcodes = array();
for ($i = 0; $i < 3; ++$i) {
/** @var \Drupal\language\Entity\ConfigurableLanguage $language */
$language = ConfigurableLanguage::create(array('id' => 'l' . $i, 'label' => 'language - ' . $i, 'weight' => $i));
$this->langcodes[$i] = $language->getId();
$language->save();
}
// Do not use a batch for tracking the initial items after creating an
// index when running the tests via the GUI. Otherwise, it seems Drupal's
// Batch API gets confused and the test fails.
\Drupal::state()->set('search_api_use_tracking_batch', FALSE);
// Create a test server.
$this->server = Server::create(array('name' => 'Test Server', 'id' => 'test_server', 'status' => 1, 'backend' => 'search_api_test_backend'));
$this->server->save();
// Create a test index.
$this->index = Index::create(array('name' => 'Test Index', 'id' => 'test_index', 'status' => 1, 'datasource_settings' => array('entity:' . $this->testEntityTypeId => array('plugin_id' => 'entity:' . $this->testEntityTypeId, 'settings' => array())), 'tracker_settings' => array('default' => array('plugin_id' => 'default', 'settings' => array())), 'server' => $this->server->id(), 'options' => array('index_directly' => FALSE)));
$this->index->save();
}
开发者ID:curveagency,项目名称:intranet,代码行数:30,代码来源:LanguageKernelTest.php
示例16: testLanguageAliases
/**
* Test that when an English node is updated, its old English alias is
* updated and its newer French alias is left intact.
*/
function testLanguageAliases()
{
// Add predefined French language.
ConfigurableLanguage::createFromLangcode('fr')->save();
$node = array('title' => 'English node', 'langcode' => 'en', 'path' => array(array('alias' => '/english-node', 'pathauto' => FALSE)));
$node = $this->drupalCreateNode($node);
$english_alias = \Drupal::service('path.alias_storage')->load(array('alias' => '/english-node', 'langcode' => 'en'));
$this->assertTrue($english_alias, 'Alias created with proper language.');
// Also save a French alias that should not be left alone, even though
// it is the newer alias.
$this->saveEntityAlias($node, '/french-node', 'fr');
// Add an alias with the soon-to-be generated alias, causing the upcoming
// alias update to generate a unique alias with the '-0' suffix.
$this->saveAlias('/node/invalid', '/content/english-node', Language::LANGCODE_NOT_SPECIFIED);
// Update the node, triggering a change in the English alias.
$node->path->pathauto = PathautoState::CREATE;
$node->save();
// Check that the new English alias replaced the old one.
$this->assertEntityAlias($node, '/content/english-node-0', 'en');
$this->assertEntityAlias($node, '/french-node', 'fr');
$this->assertAliasExists(array('pid' => $english_alias['pid'], 'alias' => '/content/english-node-0'));
// Create a new node with the same title as before but without
// specifying a language.
$node = $this->drupalCreateNode(array('title' => 'English node', 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED));
// Check that the new node had a unique alias generated with the '-1'
// suffix.
$this->assertEntityAlias($node, '/content/english-node-1', LanguageInterface::LANGCODE_NOT_SPECIFIED);
}
开发者ID:malabya,项目名称:angular-demo,代码行数:32,代码来源:PathautoLocaleTest.php
示例17: testPublishedStatusNoFields
/**
* Tests changing the published status on a node without fields.
*/
public function testPublishedStatusNoFields()
{
// Test changing the published status of an article without fields.
$this->drupalLogin($this->administrator);
// Delete all fields.
$this->drupalGet('admin/structure/types/manage/article/fields');
$this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.' . $this->fieldName . '/delete', array(), t('Delete'));
$this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.field_tags/delete', array(), t('Delete'));
$this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.field_image/delete', array(), t('Delete'));
// Add a node.
$default_langcode = $this->langcodes[0];
$values[$default_langcode] = array('title' => array(array('value' => $this->randomMachineName())));
$entity_id = $this->createEntity($values[$default_langcode], $default_langcode);
$entity = entity_load($this->entityTypeId, $entity_id, TRUE);
// Add a content translation.
$langcode = 'fr';
$language = ConfigurableLanguage::load($langcode);
$values[$langcode] = array('title' => array(array('value' => $this->randomMachineName())));
$entity_type_id = $entity->getEntityTypeId();
$add_url = Url::fromRoute("entity.{$entity_type_id}.content_translation_add", [$entity->getEntityTypeId() => $entity->id(), 'source' => $default_langcode, 'target' => $langcode], array('language' => $language));
$this->drupalPostForm($add_url, $this->getEditValues($values, $langcode), t('Save and unpublish (this translation)'));
$entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
$translation = $entity->getTranslation($langcode);
// Make sure we unpublished the node correctly.
$this->assertFalse($this->manager->getTranslationMetadata($translation)->isPublished(), 'The translation has been correctly unpublished.');
}
开发者ID:ravibarnwal,项目名称:laraitassociate.in,代码行数:29,代码来源:NodeTranslationUITest.php
示例18: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
parent::setUp();
ConfigurableLanguage::createFromLangcode('it')->save();
/** @var \Drupal\content_translation\ContentTranslationManagerInterface $manager */
$manager = \Drupal::service('content_translation.manager');
$manager->setEnabled('node', 'article', TRUE);
// Create and log in user.
$web_user = $this->drupalCreateUser(array('view page revisions', 'revert page revisions', 'delete page revisions', 'edit any page content', 'delete any page content', 'translate any entity'));
$this->drupalLogin($web_user);
// Create initial node.
$node = $this->drupalCreateNode();
$settings = get_object_vars($node);
$settings['revision'] = 1;
$settings['isDefaultRevision'] = TRUE;
$nodes = array();
$logs = array();
// Get original node.
$nodes[] = clone $node;
// Create three revisions.
$revision_count = 3;
for ($i = 0; $i < $revision_count; $i++) {
$logs[] = $node->revision_log = $this->randomMachineName(32);
// Create revision with a random title and body and update variables.
$node->title = $this->randomMachineName();
$node->body = array('value' => $this->randomMachineName(32), 'format' => filter_default_format());
$node->setNewRevision();
$node->save();
$node = Node::load($node->id());
// Make sure we get revision information.
$nodes[] = clone $node;
}
$this->nodes = $nodes;
$this->revisionLogs = $logs;
}
开发者ID:nsp15,项目名称:Drupal8,代码行数:38,代码来源:NodeRevisionsTest.php
示例19: setUp
protected function setUp()
{
parent::setUp();
// Create and login user.
$test_user = $this->drupalCreateUser(array('access content', 'search content', 'use advanced search', 'administer nodes', 'administer languages', 'access administration pages', 'administer site configuration'));
$this->drupalLogin($test_user);
// Add a new language.
ConfigurableLanguage::createFromLangcode('es')->save();
// Make the body field translatable. The title is already translatable by
// definition. The parent class has already created the article and page
// content types.
$field_storage = FieldStorageConfig::loadByName('node', 'body');
$field_storage->setTranslatable(TRUE);
$field_storage->save();
// Create a few page nodes with multilingual body values.
$default_format = filter_default_format();
$nodes = array(array('title' => 'First node en', 'type' => 'page', 'body' => array(array('value' => $this->randomMachineName(32), 'format' => $default_format)), 'langcode' => 'en'), array('title' => 'Second node this is the Spanish title', 'type' => 'page', 'body' => array(array('value' => $this->randomMachineName(32), 'format' => $default_format)), 'langcode' => 'es'), array('title' => 'Third node en', 'type' => 'page', 'body' => array(array('value' => $this->randomMachineName(32), 'format' => $default_format)), 'langcode' => 'en'));
$this->searchableNodes = [];
foreach ($nodes as $setting) {
$this->searchableNodes[] = $this->drupalCreateNode($setting);
}
// Add English translation to the second node.
$translation = $this->searchableNodes[1]->addTranslation('en', array('title' => 'Second node en'));
$translation->body->value = $this->randomMachineName(32);
$this->searchableNodes[1]->save();
// Add Spanish translation to the third node.
$translation = $this->searchableNodes[2]->addTranslation('es', array('title' => 'Third node es'));
$translation->body->value = $this->randomMachineName(32);
$this->searchableNodes[2]->save();
// Update the index and then run the shutdown method.
$plugin = $this->container->get('plugin.manager.search')->createInstance('node_search');
$plugin->updateIndex();
search_update_totals();
}
开发者ID:ddrozdik,项目名称:dmaps,代码行数:34,代码来源:SearchLanguageTest.php
示例20: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
parent::setUp();
ConfigurableLanguage::createFromLangcode('de')->save();
$this->drupalLogin($this->drupalCreateUser(['administer site configuration', 'translate configuration']));
PageVariant::create(['variant' => 'http_status_code', 'label' => 'HTTP status code', 'id' => 'http_status_code', 'page' => 'node_view'])->save();
}
开发者ID:nB-MDSO,项目名称:mdso-d8blog,代码行数:10,代码来源:PageManagerConfigTranslationTest.php
注:本文中的Drupal\language\Entity\ConfigurableLanguage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论