当前位置: 首页>>代码示例>>PHP>>正文


PHP Entity\ContentLanguageSettings类代码示例

本文整理汇总了PHP中Drupal\language\Entity\ContentLanguageSettings的典型用法代码示例。如果您正苦于以下问题:PHP ContentLanguageSettings类的具体用法?PHP ContentLanguageSettings怎么用?PHP ContentLanguageSettings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ContentLanguageSettings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: form

 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $vocabulary = $this->entity;
     if ($vocabulary->isNew()) {
         $form['#title'] = $this->t('Add vocabulary');
     } else {
         $form['#title'] = $this->t('Edit vocabulary');
     }
     $form['name'] = array('#type' => 'textfield', '#title' => $this->t('Name'), '#default_value' => $vocabulary->label(), '#maxlength' => 255, '#required' => TRUE);
     $form['vid'] = array('#type' => 'machine_name', '#default_value' => $vocabulary->id(), '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH, '#machine_name' => array('exists' => array($this, 'exists'), 'source' => array('name')));
     $form['description'] = array('#type' => 'textfield', '#title' => $this->t('Description'), '#default_value' => $vocabulary->getDescription());
     // $form['langcode'] is not wrapped in an
     // if ($this->moduleHandler->moduleExists('language')) check because the
     // language_select form element works also without the language module being
     // installed. https://www.drupal.org/node/1749954 documents the new element.
     $form['langcode'] = array('#type' => 'language_select', '#title' => $this->t('Vocabulary language'), '#languages' => LanguageInterface::STATE_ALL, '#default_value' => $vocabulary->language()->getId());
     if ($this->moduleHandler->moduleExists('language')) {
         $form['default_terms_language'] = array('#type' => 'details', '#title' => $this->t('Terms language'), '#open' => TRUE);
         $form['default_terms_language']['default_language'] = array('#type' => 'language_configuration', '#entity_information' => array('entity_type' => 'taxonomy_term', 'bundle' => $vocabulary->id()), '#default_value' => ContentLanguageSettings::loadByEntityTypeBundle('taxonomy_term', $vocabulary->id()));
     }
     // Set the hierarchy to "multiple parents" by default. This simplifies the
     // vocabulary form and standardizes the term form.
     $form['hierarchy'] = array('#type' => 'value', '#value' => '0');
     $form = parent::form($form, $form_state);
     return $this->protectBundleIdElement($form);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:29,代码来源:VocabularyForm.php

示例2: testLanguageContentWithNoLanguageLock

 /**
  * Tests migration of content language settings when there is no language lock.
  */
 public function testLanguageContentWithNoLanguageLock()
 {
     // Assert that a we can assign a language.
     $config = ContentLanguageSettings::loadByEntityTypeBundle('node', 'employee');
     $this->assertSame($config->getDefaultLangcode(), 'current_interface');
     $this->assertTrue($config->isLanguageAlterable());
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:10,代码来源:MigrateLanguageContentSettingsTest.php

示例3: form

 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $form = parent::form($form, $form_state);
     $comment_type = $this->entity;
     $form['label'] = array('#type' => 'textfield', '#title' => t('Label'), '#maxlength' => 255, '#default_value' => $comment_type->label(), '#required' => TRUE);
     $form['id'] = array('#type' => 'machine_name', '#default_value' => $comment_type->id(), '#machine_name' => array('exists' => '\\Drupal\\comment\\Entity\\CommentType::load'), '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH, '#disabled' => !$comment_type->isNew());
     $form['description'] = array('#type' => 'textarea', '#default_value' => $comment_type->getDescription(), '#description' => t('Describe this comment type. The text will be displayed on the <em>Comment types</em> administration overview page.'), '#title' => t('Description'));
     if ($comment_type->isNew()) {
         $options = array();
         foreach ($this->entityManager->getDefinitions() as $entity_type) {
             // Only expose entities that have field UI enabled, only those can
             // get comment fields added in the UI.
             if ($entity_type->get('field_ui_base_route')) {
                 $options[$entity_type->id()] = $entity_type->getLabel();
             }
         }
         $form['target_entity_type_id'] = array('#type' => 'select', '#default_value' => $comment_type->getTargetEntityTypeId(), '#title' => t('Target entity type'), '#options' => $options, '#description' => t('The target entity type can not be changed after the comment type has been created.'));
     } else {
         $form['target_entity_type_id_display'] = array('#type' => 'item', '#markup' => $this->entityManager->getDefinition($comment_type->getTargetEntityTypeId())->getLabel(), '#title' => t('Target entity type'));
     }
     if ($this->moduleHandler->moduleExists('content_translation')) {
         $form['language'] = array('#type' => 'details', '#title' => t('Language settings'), '#group' => 'additional_settings');
         $language_configuration = ContentLanguageSettings::loadByEntityTypeBundle('comment', $comment_type->id());
         $form['language']['language_configuration'] = array('#type' => 'language_configuration', '#entity_information' => array('entity_type' => 'comment', 'bundle' => $comment_type->id()), '#default_value' => $language_configuration);
         $form['#submit'][] = 'language_configuration_element_submit';
     }
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save'));
     return $form;
 }
开发者ID:ravibarnwal,项目名称:laraitassociate.in,代码行数:33,代码来源:CommentTypeForm.php

示例4: form

 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $form = parent::form($form, $form_state);
     /** @var \Drupal\commerce_product\Entity\ProductTypeInterface $product_type */
     $product_type = $this->entity;
     $variation_types = $this->variationTypeStorage->loadMultiple();
     $variation_types = array_map(function ($variation_type) {
         return $variation_type->label();
     }, $variation_types);
     // Create an empty product to get the default status value.
     // @todo Clean up once https://www.drupal.org/node/2318187 is fixed.
     if ($this->operation == 'add') {
         $product = $this->entityTypeManager->getStorage('commerce_product')->create(['type' => $product_type->uuid()]);
     } else {
         $product = $this->entityTypeManager->getStorage('commerce_product')->create(['type' => $product_type->id()]);
     }
     $form['label'] = ['#type' => 'textfield', '#title' => $this->t('Label'), '#maxlength' => 255, '#default_value' => $product_type->label(), '#required' => TRUE];
     $form['id'] = ['#type' => 'machine_name', '#default_value' => $product_type->id(), '#machine_name' => ['exists' => '\\Drupal\\commerce_product\\Entity\\ProductType::load'], '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH];
     $form['description'] = ['#type' => 'textfield', '#title' => $this->t('Description'), '#default_value' => $product_type->getDescription()];
     $form['variationType'] = ['#type' => 'select', '#title' => $this->t('Product variation type'), '#default_value' => $product_type->getVariationType(), '#options' => $variation_types, '#required' => TRUE];
     $form['product_status'] = ['#type' => 'checkbox', '#title' => t('Publish new products of this type by default.'), '#default_value' => $product->isPublished()];
     if ($this->moduleHandler->moduleExists('language')) {
         $form['language'] = ['#type' => 'details', '#title' => $this->t('Language settings'), '#group' => 'additional_settings'];
         $form['language']['language_configuration'] = ['#type' => 'language_configuration', '#entity_information' => ['entity_type' => 'commerce_product', 'bundle' => $product_type->id()], '#default_value' => ContentLanguageSettings::loadByEntityTypeBundle('commerce_product', $product_type->id())];
         $form['#submit'][] = 'language_configuration_element_submit';
     }
     return $this->protectBundleIdElement($form);
 }
开发者ID:marmouset,项目名称:drupal,代码行数:31,代码来源:ProductTypeForm.php

示例5: setUp

 protected function setUp()
 {
     parent::setUp();
     // Set up an additional language.
     $this->langcodes = array(\Drupal::languageManager()->getDefaultLanguage()->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.
     \Drupal::service('content_translation.manager')->setEnabled('node', $this->bundle, 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.
     ContentLanguageSettings::loadByEntityTypeBundle('node', $this->bundle)->setLanguageAlterable(TRUE)->setDefaultLangcode(\Drupal::languageManager()->getDefaultLanguage()->getId())->save();
     // 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:Nikola-xiii,项目名称:d8intranet,代码行数:25,代码来源:ContentTranslationContextualLinksTest.php

示例6: testVocabularyDefaultLanguageForTerms

 /**
  * Tests term language settings for vocabulary terms are saved and updated.
  */
 function testVocabularyDefaultLanguageForTerms()
 {
     // Add a new vocabulary and check that the default language settings are for
     // the terms are saved.
     $edit = array('name' => $this->randomMachineName(), 'vid' => Unicode::strtolower($this->randomMachineName()), 'default_language[langcode]' => 'bb', 'default_language[language_alterable]' => TRUE);
     $vid = $edit['vid'];
     $this->drupalPostForm('admin/structure/taxonomy/add', $edit, t('Save'));
     // Check that the vocabulary was actually created.
     $this->drupalGet('admin/structure/taxonomy/manage/' . $edit['vid']);
     $this->assertResponse(200, 'The vocabulary has been created.');
     // Check that the language settings were saved.
     $language_settings = ContentLanguageSettings::loadByEntityTypeBundle('taxonomy_term', $edit['vid']);
     $this->assertEqual($language_settings->getDefaultLangcode(), 'bb', 'The langcode was saved.');
     $this->assertTrue($language_settings->isLanguageAlterable(), 'The visibility setting was saved.');
     // Check that the correct options are selected in the interface.
     $this->assertOptionSelected('edit-default-language-langcode', 'bb', 'The correct default language for the terms of this vocabulary is selected.');
     $this->assertFieldChecked('edit-default-language-language-alterable', 'Show language selection option is checked.');
     // Edit the vocabulary and check that the new settings are updated.
     $edit = array('default_language[langcode]' => 'aa', 'default_language[language_alterable]' => FALSE);
     $this->drupalPostForm('admin/structure/taxonomy/manage/' . $vid, $edit, t('Save'));
     // And check again the settings and also the interface.
     $language_settings = ContentLanguageSettings::loadByEntityTypeBundle('taxonomy_term', $vid);
     $this->assertEqual($language_settings->getDefaultLangcode(), 'aa', 'The langcode was saved.');
     $this->assertFalse($language_settings->isLanguageAlterable(), 'The visibility setting was saved.');
     $this->drupalGet('admin/structure/taxonomy/manage/' . $vid);
     $this->assertOptionSelected('edit-default-language-langcode', 'aa', 'The correct default language for the terms of this vocabulary is selected.');
     $this->assertNoFieldChecked('edit-default-language-language-alterable', 'Show language selection option is not checked.');
     // Check that language settings are changed after editing vocabulary.
     $edit = array('name' => $this->randomMachineName(), 'default_language[langcode]' => 'authors_default', 'default_language[language_alterable]' => FALSE);
     $this->drupalPostForm('admin/structure/taxonomy/manage/' . $vid, $edit, t('Save'));
     // Check that we have the new settings.
     $new_settings = ContentLanguageSettings::loadByEntityTypeBundle('taxonomy_term', $vid);
     $this->assertEqual($new_settings->getDefaultLangcode(), 'authors_default', 'The langcode was saved.');
     $this->assertFalse($new_settings->isLanguageAlterable(), 'The new visibility setting was saved.');
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:38,代码来源:VocabularyLanguageTest.php

示例7: form

 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $form = parent::form($form, $form_state);
     /** @var \Drupal\commerce_product\Entity\ProductVariationTypeInterface $variation_type */
     $variation_type = $this->entity;
     $form['label'] = ['#type' => 'textfield', '#title' => $this->t('Label'), '#maxlength' => 255, '#default_value' => $variation_type->label(), '#required' => TRUE];
     $form['id'] = ['#type' => 'machine_name', '#default_value' => $variation_type->id(), '#machine_name' => ['exists' => '\\Drupal\\commerce_product\\Entity\\ProductVariationType::load'], '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH];
     $form['generateTitle'] = ['#type' => 'checkbox', '#title' => t('Generate variation titles based on attribute values.'), '#default_value' => $variation_type->shouldGenerateTitle()];
     if (\Drupal::moduleHandler()->moduleExists('commerce_order')) {
         // Prepare a list of line item types used to purchase product variations.
         $line_item_type_storage = $this->entityTypeManager->getStorage('commerce_line_item_type');
         $line_item_types = $line_item_type_storage->loadMultiple();
         $line_item_types = array_filter($line_item_types, function ($line_item_type) {
             return $line_item_type->getPurchasableEntityTypeId() == 'commerce_product_variation';
         });
         $line_item_types = array_map(function ($line_item_type) {
             return $line_item_type->label();
         }, $line_item_types);
         $form['lineItemType'] = ['#type' => 'select', '#title' => $this->t('Line item type'), '#default_value' => $variation_type->getLineItemTypeId(), '#options' => $line_item_types, '#empty_value' => '', '#required' => TRUE];
     }
     if ($this->moduleHandler->moduleExists('language')) {
         $form['language'] = ['#type' => 'details', '#title' => $this->t('Language settings'), '#group' => 'additional_settings'];
         $form['language']['language_configuration'] = ['#type' => 'language_configuration', '#entity_information' => ['entity_type' => 'commerce_product_variation', 'bundle' => $variation_type->id()], '#default_value' => ContentLanguageSettings::loadByEntityTypeBundle('commerce_product_variation', $variation_type->id())];
         $form['#submit'][] = 'language_configuration_element_submit';
     }
     return $this->protectBundleIdElement($form);
 }
开发者ID:alexburrows,项目名称:cream-2.x,代码行数:30,代码来源:ProductVariationTypeForm.php

示例8: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $conf = ContentLanguageSettings::loadByEntityTypeBundle('entity_test', 'some_bundle');
     $form['lang_configuration'] = array('#type' => 'language_configuration', '#entity_information' => array('entity_type' => 'entity_test', 'bundle' => 'some_bundle'), '#default_value' => $conf);
     $form['submit'] = array('#type' => 'submit', '#value' => 'Save');
     $form['#submit'][] = 'language_configuration_element_submit';
     return $form;
 }
开发者ID:318io,项目名称:318-io,代码行数:11,代码来源:LanguageConfigurationElement.php

示例9: form

 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $form = parent::form($form, $form_state);
     $store_type = $this->entity;
     $form['label'] = ['#type' => 'textfield', '#title' => $this->t('Label'), '#maxlength' => 255, '#default_value' => $store_type->label(), '#description' => $this->t('Label for the store type.'), '#required' => TRUE];
     $form['id'] = ['#type' => 'machine_name', '#default_value' => $store_type->id(), '#machine_name' => ['exists' => '\\Drupal\\commerce_store\\Entity\\StoreType::load'], '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH];
     $form['description'] = ['#type' => 'textfield', '#title' => $this->t('Description'), '#default_value' => $store_type->getDescription()];
     if ($this->moduleHandler->moduleExists('language')) {
         $form['language'] = ['#type' => 'details', '#title' => $this->t('Language settings'), '#group' => 'additional_settings'];
         $form['language']['language_configuration'] = ['#type' => 'language_configuration', '#entity_information' => ['entity_type' => 'commerce_store', 'bundle' => $store_type->id()], '#default_value' => ContentLanguageSettings::loadByEntityTypeBundle('commerce_store', $store_type->id())];
         $form['#submit'][] = 'language_configuration_element_submit';
     }
     return $this->protectBundleIdElement($form);
 }
开发者ID:alexburrows,项目名称:cream-2.x,代码行数:17,代码来源:StoreTypeForm.php

示例10: testLanguageContent

 /**
  * Tests migration of content language settings.
  */
 public function testLanguageContent()
 {
     // Assert that a translatable content is still translatable.
     $config = $this->config('language.content_settings.node.blog');
     $this->assertIdentical($config->get('target_entity_type_id'), 'node');
     $this->assertIdentical($config->get('target_bundle'), 'blog');
     $this->assertIdentical($config->get('default_langcode'), 'current_interface');
     $this->assertFalse($config->get('language_alterable'));
     $this->assertTrue($config->get('third_party_settings.content_translation.enabled'));
     // Assert that a non-translatable content is not translatable.
     $config = ContentLanguageSettings::loadByEntityTypeBundle('node', 'page');
     $this->assertTrue($config->isDefaultConfiguration());
     $this->assertFalse($config->isLanguageAlterable());
     $this->assertSame($config->getDefaultLangcode(), 'site_default');
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:18,代码来源:MigrateLanguageContentSettingsTest.php

示例11: testMenuLanguage

 /**
  * Tests menu language settings and the defaults for menu link items.
  */
 function testMenuLanguage()
 {
     // Create a test menu to test the various language-related settings.
     // Machine name has to be lowercase.
     $menu_name = Unicode::strtolower($this->randomMachineName(16));
     $label = $this->randomString();
     $edit = array('id' => $menu_name, 'description' => '', 'label' => $label, 'langcode' => 'aa');
     $this->drupalPostForm('admin/structure/menu/add', $edit, t('Save'));
     ContentLanguageSettings::loadByEntityTypeBundle('menu_link_content', 'menu_link_content')->setDefaultLangcode('bb')->setLanguageAlterable(TRUE)->save();
     // Check menu language.
     $this->assertOptionSelected('edit-langcode', $edit['langcode'], 'The menu language was correctly selected.');
     // Test menu link language.
     $link_path = '/';
     // Add a menu link.
     $link_title = $this->randomString();
     $edit = array('title[0][value]' => $link_title, 'link[0][uri]' => $link_path);
     $this->drupalPostForm("admin/structure/menu/manage/{$menu_name}/add", $edit, t('Save'));
     // Check the link was added with the correct menu link default language.
     $menu_links = entity_load_multiple_by_properties('menu_link_content', array('title' => $link_title));
     $menu_link = reset($menu_links);
     $this->assertMenuLink($menu_link->getPluginId(), array('menu_name' => $menu_name, 'route_name' => '<front>', 'langcode' => 'bb'));
     // Edit menu link default, changing it to cc.
     ContentLanguageSettings::loadByEntityTypeBundle('menu_link_content', 'menu_link_content')->setDefaultLangcode('cc')->setLanguageAlterable(TRUE)->save();
     // Add a menu link.
     $link_title = $this->randomString();
     $edit = array('title[0][value]' => $link_title, 'link[0][uri]' => $link_path);
     $this->drupalPostForm("admin/structure/menu/manage/{$menu_name}/add", $edit, t('Save'));
     // Check the link was added with the correct new menu link default language.
     $menu_links = entity_load_multiple_by_properties('menu_link_content', array('title' => $link_title));
     $menu_link = reset($menu_links);
     $this->assertMenuLink($menu_link->getPluginId(), array('menu_name' => $menu_name, 'route_name' => '<front>', 'langcode' => 'cc'));
     // Now change the language of the new link to 'bb'.
     $edit = array('langcode[0][value]' => 'bb');
     $this->drupalPostForm('admin/structure/menu/item/' . $menu_link->id() . '/edit', $edit, t('Save'));
     $this->assertMenuLink($menu_link->getPluginId(), array('menu_name' => $menu_name, 'route_name' => '<front>', 'langcode' => 'bb'));
     // Saving menu link items ends up on the edit menu page. To check the menu
     // link has the correct language default on edit, go to the menu link edit
     // page first.
     $this->drupalGet('admin/structure/menu/item/' . $menu_link->id() . '/edit');
     // Check that the language selector has the correct default value.
     $this->assertOptionSelected('edit-langcode-0-value', 'bb', 'The menu link language was correctly selected.');
     // Edit menu to hide the language select on menu link item add.
     ContentLanguageSettings::loadByEntityTypeBundle('menu_link_content', 'menu_link_content')->setDefaultLangcode('cc')->setLanguageAlterable(FALSE)->save();
     // Check that the language selector is not available on menu link add page.
     $this->drupalGet("admin/structure/menu/manage/{$menu_name}/add");
     $this->assertNoField('edit-langcode-0-value', 'The language selector field was hidden the page');
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:50,代码来源:MenuLanguageTest.php

示例12: form

 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $form = parent::form($form, $form_state);
     /* @var \Drupal\block_content\BlockContentTypeInterface $block_type */
     $block_type = $this->entity;
     $form['label'] = array('#type' => 'textfield', '#title' => t('Label'), '#maxlength' => 255, '#default_value' => $block_type->label(), '#description' => t("Provide a label for this block type to help identify it in the administration pages."), '#required' => TRUE);
     $form['id'] = array('#type' => 'machine_name', '#default_value' => $block_type->id(), '#machine_name' => array('exists' => '\\Drupal\\block_content\\Entity\\BlockContentType::load'), '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH, '#disabled' => !$block_type->isNew());
     $form['description'] = array('#type' => 'textarea', '#default_value' => $block_type->getDescription(), '#description' => t('Enter a description for this block type.'), '#title' => t('Description'));
     $form['revision'] = array('#type' => 'checkbox', '#title' => t('Create new revision'), '#default_value' => $block_type->shouldCreateNewRevision(), '#description' => t('Create a new revision by default for this block type.'));
     if ($this->moduleHandler->moduleExists('language')) {
         $form['language'] = array('#type' => 'details', '#title' => t('Language settings'), '#group' => 'additional_settings');
         $language_configuration = ContentLanguageSettings::loadByEntityTypeBundle('block_content', $block_type->id());
         $form['language']['language_configuration'] = array('#type' => 'language_configuration', '#entity_information' => array('entity_type' => 'block_content', 'bundle' => $block_type->id()), '#default_value' => $language_configuration);
         $form['#submit'][] = 'language_configuration_element_submit';
     }
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save'));
     return $form;
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:22,代码来源:BlockContentTypeForm.php

示例13: form

 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $form = parent::form($form, $form_state);
     $type = $this->entity;
     if ($this->operation == 'add') {
         $form['#title'] = $this->t('Add content type');
         $fields = $this->entityManager->getBaseFieldDefinitions('node');
         // Create a node with a fake bundle using the type's UUID so that we can
         // get the default values for workflow settings.
         // @todo Make it possible to get default values without an entity.
         //   https://www.drupal.org/node/2318187
         $node = $this->entityManager->getStorage('node')->create(array('type' => $type->uuid()));
     } else {
         $form['#title'] = $this->t('Edit %label content type', array('%label' => $type->label()));
         $fields = $this->entityManager->getFieldDefinitions('node', $type->id());
         // Create a node to get the current values for workflow settings fields.
         $node = $this->entityManager->getStorage('node')->create(array('type' => $type->id()));
     }
     $form['name'] = array('#title' => t('Name'), '#type' => 'textfield', '#default_value' => $type->label(), '#description' => t('The human-readable name of this content type. This text will be displayed as part of the list on the <em>Add content</em> page. This name must be unique.'), '#required' => TRUE, '#size' => 30);
     $form['type'] = array('#type' => 'machine_name', '#default_value' => $type->id(), '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH, '#disabled' => $type->isLocked(), '#machine_name' => array('exists' => ['Drupal\\node\\Entity\\NodeType', 'load'], 'source' => array('name')), '#description' => t('A unique machine-readable name for this content type. It must only contain lowercase letters, numbers, and underscores. This name will be used for constructing the URL of the %node-add page, in which underscores will be converted into hyphens.', array('%node-add' => t('Add content'))));
     $form['description'] = array('#title' => t('Description'), '#type' => 'textarea', '#default_value' => $type->getDescription(), '#description' => t('This text will be displayed on the <em>Add new content</em> page.'));
     $form['additional_settings'] = array('#type' => 'vertical_tabs', '#attached' => array('library' => array('node/drupal.content_types')));
     $form['submission'] = array('#type' => 'details', '#title' => t('Submission form settings'), '#group' => 'additional_settings', '#open' => TRUE);
     $form['submission']['title_label'] = array('#title' => t('Title field label'), '#type' => 'textfield', '#default_value' => $fields['title']->getLabel(), '#required' => TRUE);
     $form['submission']['preview_mode'] = array('#type' => 'radios', '#title' => t('Preview before submitting'), '#default_value' => $type->getPreviewMode(), '#options' => array(DRUPAL_DISABLED => t('Disabled'), DRUPAL_OPTIONAL => t('Optional'), DRUPAL_REQUIRED => t('Required')));
     $form['submission']['help'] = array('#type' => 'textarea', '#title' => t('Explanation or submission guidelines'), '#default_value' => $type->getHelp(), '#description' => t('This text will be displayed at the top of the page when creating or editing content of this type.'));
     $form['workflow'] = array('#type' => 'details', '#title' => t('Publishing options'), '#group' => 'additional_settings');
     $workflow_options = array('status' => $node->status->value, 'promote' => $node->promote->value, 'sticky' => $node->sticky->value, 'revision' => $type->isNewRevision());
     // Prepare workflow options to be used for 'checkboxes' form element.
     $keys = array_keys(array_filter($workflow_options));
     $workflow_options = array_combine($keys, $keys);
     $form['workflow']['options'] = array('#type' => 'checkboxes', '#title' => t('Default options'), '#default_value' => $workflow_options, '#options' => array('status' => t('Published'), 'promote' => t('Promoted to front page'), 'sticky' => t('Sticky at top of lists'), 'revision' => t('Create new revision')), '#description' => t('Users with the <em>Administer content</em> permission will be able to override these options.'));
     if ($this->moduleHandler->moduleExists('language')) {
         $form['language'] = array('#type' => 'details', '#title' => t('Language settings'), '#group' => 'additional_settings');
         $language_configuration = ContentLanguageSettings::loadByEntityTypeBundle('node', $type->id());
         $form['language']['language_configuration'] = array('#type' => 'language_configuration', '#entity_information' => array('entity_type' => 'node', 'bundle' => $type->id()), '#default_value' => $language_configuration);
     }
     $form['display'] = array('#type' => 'details', '#title' => t('Display settings'), '#group' => 'additional_settings');
     $form['display']['display_submitted'] = array('#type' => 'checkbox', '#title' => t('Display author and date information'), '#default_value' => $type->displaySubmitted(), '#description' => t('Author username and publish date will be displayed.'));
     return $this->protectBundleIdElement($form);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:44,代码来源:NodeTypeForm.php

示例14: setUpLanguages

 /**
  * Set up configuration for multiple languages.
  */
 function setUpLanguages()
 {
     // Add languages.
     $this->defaultLanguage = 'en';
     $this->secondaryLanguage = 'es';
     $this->addLanguage($this->secondaryLanguage);
     // Display the language widget.
     $config = ContentLanguageSettings::loadByEntityTypeBundle('node', 'simplenews_issue');
     $config->setLanguageAlterable(TRUE);
     $config->save();
     // Make Simplenews issue translatable.
     \Drupal::service('content_translation.manager')->setEnabled('node', 'simplenews_issue', TRUE);
     drupal_static_reset();
     \Drupal::entityManager()->clearCachedDefinitions();
     \Drupal::service('router.builder')->rebuild();
     \Drupal::service('entity.definition_update_manager')->applyUpdates();
     // Make Simplenews issue body translatable.
     $field = FieldConfig::loadByName('node', 'simplenews_issue', 'body');
     $field->setTranslatable(TRUE);
     $field->save();
     $this->rebuildContainer();
 }
开发者ID:aritnath1990,项目名称:simplenewslatest,代码行数:25,代码来源:SimplenewsI18nTest.php

示例15: createContentType

 /**
  * Creates a new node content type.
  *
  * @param string $name
  *   The content type name.
  * @param string $langcode
  *   Default language code of the nodes of this type.
  */
 protected function createContentType($name, $langcode)
 {
     $content_type = $this->container->get('entity.manager')->getStorage('node_type')->create(array('name' => 'Test ' . $name, 'title_label' => 'Title', 'type' => $name, 'create_body' => FALSE));
     $content_type->save();
     ContentLanguageSettings::loadByEntityTypeBundle('node', $name)->setLanguageAlterable(FALSE)->setDefaultLangcode($langcode)->save();
 }
开发者ID:ravibarnwal,项目名称:laraitassociate.in,代码行数:14,代码来源:EntityDefaultLanguageTest.php


注:本文中的Drupal\language\Entity\ContentLanguageSettings类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。