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


PHP VocabularyInterface::save方法代码示例

本文整理汇总了PHP中Drupal\taxonomy\VocabularyInterface::save方法的典型用法代码示例。如果您正苦于以下问题:PHP VocabularyInterface::save方法的具体用法?PHP VocabularyInterface::save怎么用?PHP VocabularyInterface::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\taxonomy\VocabularyInterface的用法示例。


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

示例1: 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

示例2: setUp

 /**
  * Sets up the test.
  */
 protected function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('entity_test_string_id');
     $this->installEntitySchema('taxonomy_term');
     $this->installEntitySchema('node');
     $this->installEntitySchema('comment');
     $this->installEntitySchema('file');
     $this->installSchema('comment', ['comment_entity_statistics']);
     $this->installSchema('node', ['node_access']);
     $this->vocabulary = Vocabulary::create(['name' => $this->randomMachineName(), 'vid' => Unicode::strtolower($this->randomMachineName()), 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED]);
     $this->vocabulary->save();
     $this->term = Term::create(['name' => $this->randomMachineName(), 'vid' => $this->vocabulary->id(), 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED]);
     $this->term->save();
     $this->entityStringId = EntityTestStringId::create(['id' => $this->randomMachineName()]);
     $this->entityStringId->save();
     // Use the util to create an instance.
     $this->createEntityReferenceField('entity_test', 'entity_test', 'field_test_taxonomy_term', 'Test content entity reference', 'taxonomy_term');
     $this->createEntityReferenceField('entity_test', 'entity_test', 'field_test_entity_test_string_id', 'Test content entity reference with string ID', 'entity_test_string_id');
     $this->createEntityReferenceField('entity_test', 'entity_test', 'field_test_taxonomy_vocabulary', 'Test config entity reference', 'taxonomy_vocabulary');
     $this->createEntityReferenceField('entity_test', 'entity_test', 'field_test_node', 'Test node entity reference', 'node', 'default', [], FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
     $this->createEntityReferenceField('entity_test', 'entity_test', 'field_test_user', 'Test user entity reference', 'user');
     $this->createEntityReferenceField('entity_test', 'entity_test', 'field_test_comment', 'Test comment entity reference', 'comment');
     $this->createEntityReferenceField('entity_test', 'entity_test', 'field_test_file', 'Test file entity reference', 'file');
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:28,代码来源:EntityReferenceItemTest.php

示例3: setupBundle

 /**
  * {@inheritdoc}
  */
 protected function setupBundle()
 {
     parent::setupBundle();
     // Create a vocabulary.
     $this->vocabulary = Vocabulary::create(['name' => $this->bundle, 'description' => $this->randomMachineName(), 'vid' => $this->bundle, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'weight' => mt_rand(0, 10)]);
     $this->vocabulary->save();
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:10,代码来源:TermTranslationUITest.php

示例4: setUp

 protected function setUp()
 {
     parent::setUp();
     // Create the vocabulary for the tag field.
     $this->vocabulary = entity_create('taxonomy_vocabulary', array('name' => 'Views testing tags', 'vid' => 'views_testing_tags'));
     $this->vocabulary->save();
     $this->term1 = $this->createTerm('term');
     $this->term2 = $this->createTerm('another');
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:9,代码来源:ViewsTaxonomyAutocompleteTest.php

示例5: setUp

 /**
  * Sets up the test.
  */
 protected function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('taxonomy_term');
     $this->vocabulary = entity_create('taxonomy_vocabulary', array('name' => $this->randomMachineName(), 'vid' => Unicode::strtolower($this->randomMachineName()), 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED));
     $this->vocabulary->save();
     $this->term = entity_create('taxonomy_term', array('name' => $this->randomMachineName(), 'vid' => $this->vocabulary->id(), 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED));
     $this->term->save();
     // Use the util to create an instance.
     $this->createEntityReferenceField('entity_test', 'entity_test', 'field_test_taxonomy_term', 'Test content entity reference', 'taxonomy_term');
     $this->createEntityReferenceField('entity_test', 'entity_test', 'field_test_taxonomy_vocabulary', 'Test config entity reference', 'taxonomy_vocabulary');
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:15,代码来源:EntityReferenceItemTest.php

示例6: mockStandardInstall

 /**
  * Provides a workaround for the inability to use the standard profile.
  *
  * @see http://drupal.org/node/1708692
  */
 protected function mockStandardInstall()
 {
     $this->drupalCreateContentType(array('type' => 'article'));
     // Create the vocabulary for the tag field.
     $this->vocabulary = entity_create('taxonomy_vocabulary', array('name' => 'Views testing tags', 'vid' => 'views_testing_tags'));
     $this->vocabulary->save();
     $field_name = 'field_' . $this->vocabulary->id();
     $handler_settings = array('target_bundles' => array($this->vocabulary->id() => $this->vocabulary->id()), 'auto_create' => TRUE);
     $this->createEntityReferenceField('node', 'article', $field_name, 'Tags', 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
     entity_get_form_display('node', 'article', 'default')->setComponent($field_name, array('type' => 'entity_reference_autocomplete_tags', 'weight' => -4))->save();
     entity_get_display('node', 'article', 'default')->setComponent($field_name, array('type' => 'entity_reference_label', 'weight' => 10))->save();
     entity_get_display('node', 'article', 'teaser')->setComponent($field_name, array('type' => 'entity_reference_label', 'weight' => 10))->save();
 }
开发者ID:brstde,项目名称:gap1,代码行数:18,代码来源:TaxonomyTestBase.php

示例7: mockStandardInstall

 /**
  * Provides a workaround for the inability to use the standard profile.
  *
  * @see http://drupal.org/node/1708692
  */
 protected function mockStandardInstall()
 {
     $this->drupalCreateContentType(array('type' => 'article'));
     // Create the vocabulary for the tag field.
     $this->vocabulary = entity_create('taxonomy_vocabulary', array('name' => 'Views testing tags', 'vid' => 'views_testing_tags'));
     $this->vocabulary->save();
     $field_name = 'field_' . $this->vocabulary->id();
     entity_create('field_storage_config', array('field_name' => $field_name, 'entity_type' => 'node', 'type' => 'taxonomy_term_reference', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, 'settings' => array('allowed_values' => array(array('vocabulary' => $this->vocabulary->id(), 'parent' => 0)))))->save();
     entity_create('field_config', array('field_name' => $field_name, 'entity_type' => 'node', 'label' => 'Tags', 'bundle' => 'article'))->save();
     entity_get_form_display('node', 'article', 'default')->setComponent($field_name, array('type' => 'taxonomy_autocomplete', 'weight' => -4))->save();
     entity_get_display('node', 'article', 'default')->setComponent($field_name, array('type' => 'taxonomy_term_reference_link', 'weight' => 10))->save();
     entity_get_display('node', 'article', 'teaser')->setComponent($field_name, array('type' => 'taxonomy_term_reference_link', 'weight' => 10))->save();
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:18,代码来源:TaxonomyTestBase.php

示例8: setUp

 protected function setUp()
 {
     parent::setUp();
     // Create two content types. One will have an autocomplete tagging field,
     // and one won't.
     $this->nodeTypeWithTags = $this->drupalCreateContentType();
     $this->nodeTypeWithoutTags = $this->drupalCreateContentType();
     // Create the vocabulary for the tag field.
     $this->tagVocabulary = entity_create('taxonomy_vocabulary', array('name' => 'Views testing tags', 'vid' => 'views_testing_tags'));
     $this->tagVocabulary->save();
     // Create the tag field itself.
     $this->tagFieldName = 'field_views_testing_tags';
     $handler_settings = array('target_bundles' => array($this->tagVocabulary->id() => $this->tagVocabulary->id()), 'auto_create' => TRUE);
     $this->createEntityReferenceField('node', $this->nodeTypeWithTags->id(), $this->tagFieldName, NULL, 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
     entity_get_form_display('node', $this->nodeTypeWithTags->id(), 'default')->setComponent($this->tagFieldName, array('type' => 'entity_reference_autocomplete_tags'))->save();
     entity_get_display('node', $this->nodeTypeWithTags->id(), 'default')->setComponent($this->tagFieldName, array('type' => 'entity_reference_label', 'weight' => 10))->save();
     entity_get_display('node', $this->nodeTypeWithTags->id(), 'teaser')->setComponent('field_views_testing_tags', array('type' => 'entity_reference_label', 'weight' => 10))->save();
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:18,代码来源:TaggedWithTest.php

示例9: setUp

 /**
  * Prepares the testing environment
  */
 public function setUp()
 {
     parent::setUp();
     // Create Basic page and Article node types.
     if ($this->profile != 'standard') {
         $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic Page'));
         $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
         $this->addDefaultCommentField('node', 'article');
     }
     // Creating a vocabulary to associate taxonomy terms generated.
     $this->vocabulary = entity_create('taxonomy_vocabulary', array('name' => $this->randomMachineName(), 'description' => $this->randomMachineName(), 'vid' => Unicode::strtolower($this->randomMachineName()), 'langcode' => Language::LANGCODE_NOT_SPECIFIED, 'weight' => mt_rand(0, 10)));
     $this->vocabulary->save();
     // Creates a field of an entity reference field storage on article.
     $field_name = 'taxonomy_' . $this->vocabulary->id();
     $handler_settings = array('target_bundles' => array($this->vocabulary->id() => $this->vocabulary->id()), 'auto_create' => TRUE);
     $this->createEntityReferenceField('node', 'article', $field_name, NULL, 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
     entity_get_form_display('node', 'article', 'default')->setComponent($field_name, array('type' => 'options_select'))->save();
     entity_get_display('node', 'article', 'default')->setComponent($field_name, array('type' => 'entity_reference_label'))->save();
     $admin_user = $this->drupalCreateUser(array('administer devel_generate'));
     $this->drupalLogin($admin_user);
 }
开发者ID:AllieRays,项目名称:debugging-drupal-8,代码行数:24,代码来源:DevelGenerateTest.php

示例10: setUp

 protected function setUp()
 {
     parent::setUp();
     $type = $this->drupalCreateContentType(array('type' => 'article'));
     // Create the vocabulary for the tag field.
     $this->vocabulary = entity_create('taxonomy_vocabulary', array('name' => 'quickedit testing tags', 'vid' => 'quickedit_testing_tags'));
     $this->vocabulary->save();
     $this->field_name = 'field_' . $this->vocabulary->id();
     entity_create('field_storage_config', array('name' => $this->field_name, 'entity_type' => 'node', 'type' => 'taxonomy_term_reference', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, 'settings' => array('allowed_values' => array(array('vocabulary' => $this->vocabulary->id(), 'parent' => 0)))))->save();
     entity_create('field_instance_config', array('field_name' => $this->field_name, 'entity_type' => 'node', 'label' => 'Tags', 'bundle' => 'article'))->save();
     entity_get_form_display('node', 'article', 'default')->setComponent($this->field_name, array('type' => 'taxonomy_autocomplete', 'weight' => -4))->save();
     entity_get_display('node', 'article', 'default')->setComponent($this->field_name, array('type' => 'taxonomy_term_reference_link', 'weight' => 10))->save();
     entity_get_display('node', 'article', 'teaser')->setComponent($this->field_name, array('type' => 'taxonomy_term_reference_link', 'weight' => 10))->save();
     $this->term1 = $this->createTerm();
     $this->term2 = $this->createTerm();
     $node = array();
     $node['type'] = 'article';
     $node[$this->field_name][]['target_id'] = $this->term1->id();
     $node[$this->field_name][]['target_id'] = $this->term2->id();
     $this->node = $this->drupalCreateNode($node);
     $this->editor_user = $this->drupalCreateUser(array('access content', 'create article content', 'edit any article content', 'access in-place editing'));
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:22,代码来源:QuickEditAutocompleteTermTest.php

示例11: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->drupalCreateContentType(array('type' => 'article'));
     // Create the vocabulary for the tag field.
     $this->vocabulary = entity_create('taxonomy_vocabulary', ['name' => 'quickedit testing tags', 'vid' => 'quickedit_testing_tags']);
     $this->vocabulary->save();
     $this->fieldName = 'field_' . $this->vocabulary->id();
     $handler_settings = array('target_bundles' => array($this->vocabulary->id() => $this->vocabulary->id()), 'auto_create' => TRUE);
     $this->createEntityReferenceField('node', 'article', $this->fieldName, 'Tags', 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
     entity_get_form_display('node', 'article', 'default')->setComponent($this->fieldName, ['type' => 'entity_reference_autocomplete_tags', 'weight' => -4])->save();
     entity_get_display('node', 'article', 'default')->setComponent($this->fieldName, ['type' => 'entity_reference_label', 'weight' => 10])->save();
     entity_get_display('node', 'article', 'teaser')->setComponent($this->fieldName, ['type' => 'entity_reference_label', 'weight' => 10])->save();
     $this->term1 = $this->createTerm();
     $this->term2 = $this->createTerm();
     $node = array();
     $node['type'] = 'article';
     $node[$this->fieldName][]['target_id'] = $this->term1->id();
     $node[$this->fieldName][]['target_id'] = $this->term2->id();
     $this->node = $this->drupalCreateNode($node);
     $this->editorUser = $this->drupalCreateUser(['access content', 'create article content', 'edit any article content', 'access in-place editing']);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:22,代码来源:QuickEditAutocompleteTermTest.php

示例12: setUp

 protected function setUp()
 {
     parent::setUp();
     // Create two content types. One will have an autocomplete tagging field,
     // and one won't.
     $this->nodeTypeWithTags = $this->drupalCreateContentType();
     $this->nodeTypeWithoutTags = $this->drupalCreateContentType();
     // Create the vocabulary for the tag field.
     $this->tagVocabulary = entity_create('taxonomy_vocabulary', array('name' => 'Views testing tags', 'vid' => 'views_testing_tags'));
     $this->tagVocabulary->save();
     // Create the tag field itself.
     $this->tagFieldName = 'field_views_testing_tags';
     $this->tagFieldStorage = entity_create('field_storage_config', array('field_name' => $this->tagFieldName, 'entity_type' => 'node', 'type' => 'taxonomy_term_reference', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, 'settings' => array('allowed_values' => array(array('vocabulary' => $this->tagVocabulary->id(), 'parent' => 0)))));
     $this->tagFieldStorage->save();
     // Create an instance of the tag field on one of the content types, and
     // configure it to display an autocomplete widget.
     $this->tagField = array('field_storage' => $this->tagFieldStorage, 'bundle' => $this->nodeTypeWithTags->id());
     entity_create('field_config', $this->tagField)->save();
     entity_get_form_display('node', $this->nodeTypeWithTags->id(), 'default')->setComponent('field_views_testing_tags', array('type' => 'taxonomy_autocomplete'))->save();
     entity_get_display('node', $this->nodeTypeWithTags->id(), 'default')->setComponent('field_views_testing_tags', array('type' => 'taxonomy_term_reference_link', 'weight' => 10))->save();
     entity_get_display('node', $this->nodeTypeWithTags->id(), 'teaser')->setComponent('field_views_testing_tags', array('type' => 'taxonomy_term_reference_link', 'weight' => 10))->save();
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:22,代码来源:TaggedWithTest.php

示例13: testTaxonomyTermFieldChangeMachineName

 /**
  * Tests that vocabulary machine name changes are mirrored in field definitions.
  */
 function testTaxonomyTermFieldChangeMachineName()
 {
     // Add several entries in the 'allowed_values' setting, to make sure that
     // they all get updated.
     $this->fieldStorage->setSetting('allowed_values', [array('vocabulary' => $this->vocabulary->id(), 'parent' => '0'), array('vocabulary' => $this->vocabulary->id(), 'parent' => '0'), array('vocabulary' => 'foo', 'parent' => '0')]);
     $this->fieldStorage->save();
     // Change the machine name.
     $new_name = Unicode::strtolower($this->randomMachineName());
     $this->vocabulary->set('vid', $new_name);
     $this->vocabulary->save();
     // Check that the field is still attached to the vocabulary.
     $field_storage = FieldStorageConfig::loadByName('entity_test', $this->fieldName);
     $allowed_values = $field_storage->getSetting('allowed_values');
     $this->assertEqual($allowed_values[0]['vocabulary'], $new_name, 'Index 0: Machine name was updated correctly.');
     $this->assertEqual($allowed_values[1]['vocabulary'], $new_name, 'Index 1: Machine name was updated correctly.');
     $this->assertEqual($allowed_values[2]['vocabulary'], 'foo', 'Index 2: Machine name was left untouched.');
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:20,代码来源:TermFieldTest.php


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